Ich bekomme 500 interne Server Fehler auf eine ajax
Post Anfrage. Ich teste es auf localhost, meine Route ist auch genau.Erhalten von 500 internen Server Fehler auf AJAX Post Anfrage
Ich habe die Route für diesen Aufruf geschrieben nicht Controller Name und Methode in der URL aufrufen.
Mein Code ist unten, jede Hilfe wäre willkommen.
$('#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;
});
Mein PHP-Code ist:
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));
}
}
}
Ein Fehler 500 würde von der Seite kommen, die du einreichst, nicht von deiner Javascript Funktion. Überprüfen Sie Ihre PHP-Datei und überprüfen Sie Ihre Serverfehlerprotokolle. 500 ist eine sehr allgemeine Nachricht, die besagt, dass der Server die Anforderung nicht verarbeiten konnte. – aynber
Was ist die PHP, wo Sie dies verarbeiten? – Qirel
Was ist Ihr Dateityp ist .js oder .php? – C2486