I have a jquery.ajax procedure that calls a php script. The PHP script searches the Google search API and returns json to the calling ajax script.
The script works fine on 99% of the installations, however, on some, when I call:
error: function(jqXHR, textStatus, errorThrown){ alert('HTTP Error: '+errorThrown+' | Error Message: '+textStatus); }
It returns:
HTTP error: SyntaxError: Unexpected token <| Error message: parsererror
How can I fix this using javascript console or chrome developer tools? Code plug below ...
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; } });
UPDATE: OBJECT Console.log Error:
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"
source share