I have this function to get the server id from the list. The function always returns "parsererror". I looked at the JSON data, but I can't get it to work, since jQuery rewrote ajax in version 1.5.
function server_id() { $.ajax({ type: "GET", url: "http://localhost/server_list.php", dataType: "json", success: function(data, status) { alert(status + "\n\n" + data.server_id); }, complete: function(data, status){ alert(status); } }); }
server_list.php
header('Content-type: application/json'); $output['server_id'] = '123'; print json_encode($output);
In firebug Net → XHR reads it as JSON when it opens a tab, and the Response tab shows that below.
{"server_id":"123"}
I also tried setting the content type header as below, but no luck.
Content-type: application/json
UPDATED
I get "parsererror" if the validation plugin is downloaded from http://bassistance.de/jquery-plugins/jquery-plugin-validation docs.jquery.com/Plugins/Validation v1.7.
If you add a jquery flash drive, it will automatically add the jsonp callback to the query string, even if you set it to false or do not enable parms for jsonp. Very strange
Any ideas on how to fix it?
thanks
Clairetaylor
source share