我的脚本返回[object Object]
为console.log(result)
的结果。console.log(result)返回[object Object]。我如何获得result.name?
有人可以请解释如何有console.log
返回id
和name
result
?
$.ajaxSetup({ traditional: true });
var uri = "";
$("#enginesOuputWaiter").show();
$.ajax({
type: "GET",
url: uri,
dataType: "jsonp",
ContentType:'application/javascript',
data :{'text' : article},
error: function(result) {
$("#enginesOuputWaiter").hide();
if(result.statusText = 'success') {
console.log("ok");
console.log(result);
} else {
$("#enginesOuput").text('Invalid query.');
}
}
});
你尝试解析它? '[object Object]'只是一个字符串表示,而不是对象的实际外观。 – Carcigenicate
该webservice似乎返回JSON而不是JSONP,所以你应该改变你的'dataType'。这也可能是为什么你的**'error' **处理程序被调用的地方,你很难得到一个成功的结果。 – Bergi
你在你的反应已经BOM符号:http://joxi.ru/vAWVVbh1k34N2W所以修复你的PHP代码,清理不必要的utf8编码的BOM – num8er