php – CodeIgniter jQuery UI autocomplete = 500内部服务器错
发布时间:2020-12-13 21:40:45 所属栏目:PHP教程 来源:网络整理
导读:这是视图代码: htmlhead script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"/script !-- Load JQuery UI -- script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jq
这是视图代码:
<html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <!-- Load JQuery UI --> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script type="text/javascript"> $( function() { $("#input").autocomplete({ source: function(req,add){ $.ajax({ url: '<?php echo base_url(); ?>test/ac2',dataType: 'json',type: 'POST',//data: req,data: 'input='+req,success: function(data){ if(data.response =='true'){ add(data.message); } } }); },minLength: 2,select: function(event,ui){ $(this).end().val(ui.item.value); } }); }); </script> </head> <?php echo form_open(); echo form_input('input','','id="input"'); echo form_close(); ?> </html> 和控制器代码: class Test extends CI_Controller { function index() { $this->load->view('vw/test_vw'); } public function ac2() { //$search = $this->input->post('term'); $search = $this->input->post('input'); $data['response'] = 'false'; $this->db->select('*'); $this->db->from('loc_exercise'); $this->db->like('locations',$search); $locations = $this->db->get()->result(); if (count($locations) > 0) { $data['message'] = array(); foreach ($locations as $location) { $data['message'][] = array( 'label' => $location->locations,'item' => $location->locations,'value' => $location->locations ); } $data['response'] = 'true'; } echo json_encode($data); } 当我在输入框中输入任何内容时,我会在控制台上输入: POST http://my.example.com/test/ac2 500 (Internal Server Error) 在CI错误日志上似乎没有问题(log_threshold是1,/ logs是chmod 777). 顺便说一句,我有我的config.php,query_strings为TRUE,allow_get_array为TRUE. 有任何想法如何解决这个问题? 解决方法
这几乎肯定是CSRF令牌问题.
见this in the CI forums和blog post (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |