CodeIgniter + jQuery UI autocomplete = 500内部服务器错误(带代码)

编程入门 行业动态 更新时间:2024-10-28 14:31:04
本文介绍了CodeIgniter + jQuery UI autocomplete = 500内部服务器错误(带代码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

以下是视图代码:

<html> <head> <script type="text/javascript" src="ajax.googleapis/ajax/libs/jquery/1.5/jquery.min.js"></script> <!-- Load JQuery UI --> <script type="text/javascript" src="ajax.googleapis/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); }

当我在输入框中输入任何内容时,

When I type anything in into the input box I get this on the console:

POST my.example/test/ac2 500 (Internal Server Error)

,并且在CI错误日志上似乎没有问题(log_threshold为1,/ logs为chmod 777)。

and on CI error logs there seems to be no issues (log_threshold is 1, /logs is chmod 777).

我有我的config.php与query_strings TRUE和allow_get_array TRUE。

BTW I have my config.php with query_strings TRUE and allow_get_array TRUE.

任何想法如何解决这个问题? p>

Any ideas how to fix this issue?

推荐答案

这几乎肯定是一个CSRF令牌问题。

This is almost certainly a CSRF token issue.

href =codeigniter/forums/viewthread/176318/ =nofollow>这在CI论坛和这 blog post

See this in the CI forums and this blog post

更多推荐

CodeIgniter + jQuery UI autocomplete = 500内部服务器错误(带代码)

本文发布于:2023-11-01 07:32:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1548674.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   代码   服务器   jQuery   CodeIgniter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!