2016-04-17 9 views
0

私はこのAJAXリクエストCodeIgniterの内部サーバーエラー

$.ajax({ 
    type : 'POST', 
    url : '<?php echo base_url('Home_controller/editUser'); ?>', 
    data : { user_id : user_id, name : name, position : position, office : office, password : password, reports_to : reports_to, user_type : user_type, status : status }, 
    dataType : 'json', 
    success : function(data){ 
     $('#name' + numberId).html(this.name); 
     $('#position' + numberId).html(this.position); 
     $('#office' + numberId).html(this.office); 
     $('#password' + numberId).html(this.password); 
     $('#reports_to' + numberId).html(this.reports_to); 
     $('#user_type' + numberId).html(this.user_type); 
     if(this.status == 1){ 
      $('#status' + numberId).html("Activated"); 
     } 
     else if(this.status == 0){ 
      $('#status' + numberId).html("Deactivated"); 
     } 

     $('#edit_user_modal').modal('toggle'); 
    }, 
    error : function(errorw){ 
     alert('Error'); 
    } 
}); 

これは私Home_controller

public function editUser(){ 
    $user_id = $this->input->post('user_id'); 
    $name = $this->input->post('name'); 
    $position = $this->input->post('position'); 
    $office = $this->input->post('office'); 
    $password = $this->input->post('password'); 
    $reports_to = $this->input->post('reports_to'); 
    $user_type = $this->input->post('user_type'); 
    $status = $this->input->post('status'); 

    $this->home_model->updateUser($user_id, $name, $position, $office, $password, $reports_to, $user_type, $status); 

    $user_details = $this->home_model->getUserDetails($user_id); 
    echo json_encode($user_details); 
} 

の私editUser方法である持っている私は私のデータのすべての値にalertを使用し、それらはすべて正しいです。私はまた、URLをチェックし、それが正しいです。私はどこが間違っていたのだろうか?誰かが私を助けてくれますか?

これはエラーjquery-2.2.1.js:9175 POST http://localhost/ppmp/Home_controller/editUser 500 (Internal Server Error)です。新しいタブでエラーのURLを開こうとしましたが、それが見つかる可能性があります。

私はここ数時間ここで立ち往生しています。助けてくれてありがとう。

+0

を必要とし、結果をproccess。サーバーのエラーログには何が表示されますか? – Quentin

+0

これはアクセスログ ':: 1 - - [18/Apr/2016:04:16:21 +0800]から得られたものです" POST/ppmp/Home_controller/editUser HTTP/1.1 "500 1460' –

+1

PHP Home_controller、editUserメソッド。リクエストが来て、それをデバッグしようとしたら – Mate

答えて

0

私はSE、あなたが持っているあなたのAjaxのリクエストであることであるという問題点:

$.ajax({ 
    type : 'POST', 
    url : '<?php echo base_url('Home_controller/editUser'); ?>', 
    data : { user_id : user_id, name : name, position : position, office : office, password : password, reports_to : reports_to, user_type : user_type, status : status }, 
    dataType : 'json', 

とヨーヨーが持っているあなたのコントローラで:

$user_id = $this->input->post('user_id'); 
    $name = $this->input->post('name'); 
    $position = $this->input->post('position'); 
    $office = $this->input->post('office'); 

問題は、あなたのようにリクエストを送信することですjsonですが、値をポストとして取得するには、リクエストをjsonから通常の文字列に変更する必要があります。

は、一方では、あなたは、コントローラの値を取得することができます:

$values = $this->input->get_post($_GET); 

$new_format = jason_decode($values); 

を、あなたはそれが内部サーバーエラーです