【问题标题】:help for debug my code in jQuery-ajax!?帮助在 jQuery-ajax 中调试我的代码!?
【发布时间】:2011-07-31 08:26:21
【问题描述】:

为什么我的代码在点击按钮提交并点击链接搜索后出现此错误:
我使用codeigniter。

An error has occured:
[object Object]
error

这是我的 Tour_foreign->CI_Controller:

function search_customer(){ 
    $customer_number = $this->input->post('customer_number');
    $query = $this->db->get_where('customer', array('customer_number' => $customer_number));
    if($query->num_rows()==0){
                echo '0';
            }else{
                $data = array();
                foreach ($query->result() as $row)
                {
                   $data[] = $row;
                }
                echo json_encode($data);
            }
    }

function insert_customers(){
    $customer_number = "";
    for($i = 0; $i < 10; $i++)
    $customer_number .= mt_rand(0, 9);
    /*////////////////////////////////////*/
    $jdate = jgmdate("j F Y");
        /*////////////////////////////////////*/
        $useradmin = $this->session->userdata('login');
        $query = $this->db->get_where('login', array('useradmin' => $useradmin))->row();
        $nameadmin = $query->nameadmin;
        $lastnameadmin = $query->lastnameadmin;
        /*////////////////////////////////////*/
    $data = array (
                'customer_number' => $customer_number,
        'name' => $this->input->post('name'),
        'name_en' => $this->input->post('name_en'),
        'father_name' => $this->input->post('father_name'),
        'number_birth_certificate' => $this->input->post('number_birth_certificate'),
        'national_number' => $this->input->post('national_number'),
        'passport_number' => $this->input->post('passport_number'),
        'term_passport' => $this->input->post('term_passport'),
        'date_of_birth' => $this->input->post('date_of_birth') ,
                'phone' => $this->input->post('phone'),
        'mobile' => $this->input->post('mobile'),
                'address' => $this->input->post('address'),
                'nationality' => $this->input->post('nationality'),
        'accommodation' => $this->input->post('accommodation'),
        'education' => $this->input->post('education'),
        'zip_code' => $this->input->post('zip_code'),
        'marital_status' => $this->input->post('marital_status'),
        'bank_name' => $this->input->post('bank_name'),
                'branch_name' => $this->input->post('branch_name'),
        'card_number' => $this->input->post('card_number'),
        'account_number' => $this->input->post('account_number'),
        'zip_code' => $this->input->post('zip_code'),
        'job' => $this->input->post('job'),
                'date_submit' => $jdate,
        'useradmin_submit' => $nameadmin.'&nbsp;'.$lastnameadmin ,
    );
    //if(!empty($data)){
        $this->db->insert('customer', $data);
        //}
    }

【问题讨论】:

  • 你试过在firebug中调试代码吗?我可以看到您收到 500 内部服务器错误。
  • 是的,我在 firebug 和 chorme 控制台中尝试过,但结果不是
  • 但我看到和我说的一样的错误
  • 当事件发生时调试服务器端代码会发生什么,500 Internal Server Error是什么?

标签: php javascript codeigniter jquery


【解决方案1】:

当我尝试使用此脚本时,我在萤火虫的控制台中看到以下错误: NetworkError: 500 内部服务器错误

这就是出现错误的原因。修复服务器部分。 尝试清理 search_customer() 函数中的所有代码并查看它是否运行。如果这个方法永远不会被执行,那么问题就出在你的框架之外吗?

然后,逐行查看服务器上发生了什么。查询可能有问题?但通常错误 500 是当您遇到 mod_rewrite 问题时。

【讨论】:

  • 但是服务器上有文件tour_foreign.php,为什么这个链接有错误500(内部服务器错误?不是本地主机上的这个错误,并且有我在顶级帖子中说的同样的错误
  • 尝试在 search_customer() 的第一行插入 die("this is test") 然后你就会知道问题出在哪里 - 你会知道问题是由 search_customer 函数引起的还是外部的一些想法
猜你喜欢
  • 2013-08-12
  • 2013-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-24
  • 1970-01-01
  • 1970-01-01
  • 2015-11-30
相关资源
最近更新 更多