このエラーの原因は何ですか?どうすれば修正できますか? Google Chromeので エラー:IE9とajax呼び出しでブラウザによって異なるエラーが発生する
An error has occured: [object Object] parsererror SyntaxError: JSON.parse: Unable to parse value:
エラー:オペラと
An error has occured: [object Object] parsererror SyntaxError: Unexpected token ILLEGAL
エラー
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_Model
function search_hotel($searchterm)
{
return mysql_query("select * from hotel_submits where name LIKE '".$searchterm."'");
}
実際の応答は何ですか? – SLaks
JSONレスポンスのようなこのサウンドは無効ですが、どのように見えますか? – enricog
火かき棒をチェックしてください。あなたは何のjsonを入手し、 'www.jsonlint.com'でjsonを確認してください。 – Rafay