2017-01-16 112 views
-1

我在ajax发布请求中收到500个内部服务器错误。我在localhost上测试它,我的路线也是准确的。在ajax发布请求中获取500个内部服务器错误

我已经编写了此调用的路由,而不是在url中调用控制器名称和方法。

我的代码如下,任何帮助将不胜感激。

$('#personal-info').click(function(){ 
    // Var paramstr = $("#personal-info").serialize(); 
    var form_data = {   //repair 
      firstname: $('#firstname').val(), 
      lastname: $('#lastname').val(), 
      fathername: $('#fathername').val(), 
      cnic: $('#cnic').val(), 
      gender: $('#gender').val(), 
      marital_status: $('#marital_status').val(), 
      day_of_birth: $('#day_of_birth').val(), 
      month_of_birth: $('#month_of_birth').val(), 
      year_of_birth: $('#year_of_birth').val(), 
      email: $('#email').val(), 
      phone: $('#phone').val(), 
      postal_code: $('#postal_code').val(), 
      country_id: $('#country_id').val(), 
      state_id: $('#state_id').val(), 
      industry_id: $('#industry_id').val(), 
      experienc_level: $('#experienc_level').val(), 
      current_salary: $('#current_salary').val(), 
      expected_salary: $('#expected_salary').val(), 
      salary_currency: $('#salary_currency').val(), 
      address: $('#address').val(), 
      skype: $('#skype').val(), 
      professional_summary: $('#professional_summary').val(), 
      face_book: $('#face_book').val(), 
      twitter: $('#twitter').val(), 
      linkedin: $('#linkedin').val(), 
      blog: $('#blog').val(), 
      website: $('#website').val(), 
      // created_at: $('#created_at').val() 
     }; 


    $.ajax({ 
     url: "<?php echo base_url('add_personal_info'); ?>",//repair 
     type: 'POST', 
     data: form_data, // $(this).serialize(); you can use this too 
     success: function(msg) { 
       alert("success..!! or any stupid msg"); 
     } 

    }); 
    return false; 

}); 

我的PHP代码:

public function add_candidate_personal_info(){ 

    $candidate = $this->input->post(); 
    $this->load->model('common_model'); 
    // $this->load->library('form_validation'); 
    $this->load->helper('common_helper'); 
    $this->load->model('User_model'); 

    $this->form_validation->set_rules('firstname', 'First Name', 'required'); 
    $this->form_validation->set_rules('lastname', 'Last Name', 'required'); 
    $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[candidate.email]'); 
    $this->form_validation->set_rules('password', 'Password', 'required|min_length[6]'); 
    if (empty($_FILES['userfile']['name'])) 
    { 
     $this->form_validation->set_rules('userfile', 'File Upload', 'required'); 
    } 

    if($this->form_validation->run()==FALSE){ 
    $formError = validation_errors(); 
    $this->data['errorMessage'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); 
    $this->load->view('front/user/candidate/add', $this->data); 
    // redirect('register_candidate'); 
    } 
    else { 
    $personal_data = array(
     'firstname' => $this->input->post('firstname'), 
     'lastname' => $this->input->post('lastname'), 
     'father_name' => $this->input->post('father_name'), 
     'cnic' => $this->input->post('cnic'), 
     'gender' => $this->input->post('gender'), 
     'marital_status' => $this->input->post('marital_status'), 
     'day_of_birth' => $this->input->post('day_of_birth'), 
     'month_of_birth' => $this->input->post('month_of_birth'), 
     'year_of_birth' => $this->input->post('year_of_birth'), 
     'email' => $this->input->post('email'), 
     'phone' => $this->input->post('phone'), 
     'postal_code' => $this->input->post('postal_code'), 
     'country_id' => $this->input->post('country_id'), 
     'state_id' => $this->input->post('state_id'), 
     'industry_id' => $this->input->post('industry_id'), 
     'experienc_level' => $this->input->post('experienc_level'), 
     'current_salary' => $this->input->post('current_salary'), 
     'expected_salary' => $this->input->post('expected_salary'), 
     'salary_currency' => $this->input->post('salary_currency'), 
     'address' => $this->input->post('address'), 
     'skype' => $this->input->post('skype'), 
     'professional_summary' => $this->input->post('professional_summary'), 
     'face_book' => $this->input->post('face_book'), 
     'twitter' => $this->input->post('twitter'), 
     'linkedin' => $this->input->post('linkedin'), 
     'blog' => $this->input->post('blog'), 
     'website' => $this->input->post('website'), 
     'created_at' => date('Y-m-d H:i'), 
    ); 

    if ($this->common_model->insert('candidate_resume_profile', $personal_data)) { 
      $this->ajaxResponse['status'] = 200; 
      $this->ajaxResponse['message'] = $this->message->success('Candidate Personal Information is Successfully Added'); 
      $this->ajaxResponse['data'] = ''; 
      exit(json_encode($this->ajaxResponse)); 
     } else { 
      $this->ajaxResponse['status'] = 500; 
      $this->ajaxResponse['message'] = $this->message->error('Internal Error'); 
      $this->ajaxResponse['data'] = ''; 
      exit(json_encode($this->ajaxResponse)); 
     } 

    } 
} 
+2

错误500将来自您要提交的页面,而不是您的JavaScript函数。检查你的PHP文件,并检查你的服务器错误日志。 500是一个非常通用的消息,说服务器无法处理请求。 – aynber

+0

什么是你处理这个PHP? – Qirel

+0

你的文件类型是.js还是.php? – C2486

回答

0

我觉得你可以了浏览器的信息,或者你可以查找的Nginx/Apache的error.log中 在Linux中,你可以使用命令找到error.log以查找您的error.log

相关问题