脚本宝典收集整理的这篇文章主要介绍了php – CodeIgniter jQuery UI autocomplete = 500内部服务器错误(带代码),脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<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.
有任何想法如何解决这个问题?
以上是脚本宝典为你收集整理的php – CodeIgniter jQuery UI autocomplete = 500内部服务器错误(带代码)全部内容,希望文章能够帮你解决php – CodeIgniter jQuery UI autocomplete = 500内部服务器错误(带代码)所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。