我有一个调用php脚本的jquery.ajax例程.php脚本在Google搜索API上进行查找,并将json返回给调用的ajax脚本.
该脚本在99%的安装上运行良好,但是,在我调用时,有几个:
error: function(jqXHR, textStatus, errorThrown){
alert('HTTP Error: '+errorThrown+' | Error Message: '+textStatus);
}
Run Code Online (Sandbox Code Playgroud)
它返回:
HTTP错误:SyntaxError:意外的令牌 <| 错误消息: parsererror
如何使用javascript控制台或chrome开发人员工具对此进行故障排除?代码存根如下......
var result='';
jQuery.ajax
({
contentType: "application/json; charset=utf-8",
dataType: "json",
url: <?php echo '"' .plugins_url('/script.php', __FILE__); ?>?Query="+ jQuery('#search_keyword').val(),
success: function(data)
{
//do something with results
},
error: function(jqXHR, textStatus, errorThrown){
console.log(arguments);
alert('HTTP Error: '+errorThrown+' | Error Message: '+textStatus);
return;
}
});
Run Code Online (Sandbox Code Playgroud)
更新:Console.log的OBJECT错误如下:
responseText: "<br />?<b>Warning</b>: array_map() [<a href='function.array-map'>function.array-map</a>]: Argument #2 should be an array in <b>/filepath/wp-content/plugins/test/test.php</b> on line <b>75</b><br />?<br />?<b>Warning</b>: Invalid argument supplied for foreach() in <b>/filepath/wp-content/plugins/test/test.php</b> on line <b>90</b><br />?No Records Returned. Search may be down. Wait a few minutes"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14888 次 |
| 最近记录: |