gpt4 book ai didi

javascript - ajax 调用中不同浏览器的不同错误

转载 作者:行者123 更新时间:2023-11-30 18:41:38 25 4
gpt4 key购买 nike

这个错误的原因是什么?我该如何解决?谷歌浏览器错误:

An error has occured: [object Object] parsererror SyntaxError: Unexpected token ILLEGAL

歌剧错误:

An error has occured: [object Object] parsererror SyntaxError: JSON.parse: Unable to parse value:

ie9 错误:

An error has occured: [object Object] parsererror SyntaxError: Invalid character

和...

js代码:

$('#hotel').keypress(function () {
var dataObj = $(this).closest('form').serializeArray();
$.ajax({
url: 'http://localhost/mehdi/admin/tour/search_hotel',
data: dataObj,
dataType: 'json',
success: function (data) {
$("#suggestion_tab").html('');
$.each(data.suggestions, function (a, b) {
$("#suggestion_tab").append('<li>' + data.b + '</li>');
});
// Display the results
///alert(data);
},
"error": function (x, y, z) {
// callback to run if an error occurs
alert("An error has occured:\n" + x + "\n" + y + "\n" + z);
}
});
});

php:(CI_Controller)

function search_hotel(){
$searchterm = $this->input->post('search_hotel');
$result = $this->model_tour->search_hotel($searchterm);
while($row = mysql_fetch_assoc($result))
{
$output[] = $row;
}
echo json_encode(array('suggestions' => $output));
}

CI_模型

function search_hotel($searchterm)
{
return mysql_query("select * from hotel_submits where name LIKE '".$searchterm."'");
}

最佳答案

您的 JSON 包含无效语法。
您需要查看实际的 JSON 并修复错误。

关于javascript - ajax 调用中不同浏览器的不同错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6693810/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com