Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
90
rated 0 times [  92] [ 2]  / answers: 1 / hits: 24301  / 13 Years ago, fri, august 12, 2011, 12:00:00

I have a web page that returns this JSON when called:



[{id:53,desc:Roberts}]


I am using this jQuery to call it by AJAX:



$.ajax ({
url: rootPath + data/topology/stations,
dataType: 'json',
data: { areaID: $(#lbxArea).val () },
success: function (data) {
// Use data for actions
},
error: function (jqXHR, textStatus, errorThrown) {
alert (textStatus);
alert (errorThrown);
}
});


I used Firebug to confirm that the data being returned is what I put on top. Despite that, I fall into the error callback and first see parsererror in an alert box, and then I see



SyntaxError: JSON.parse: expected property name or '}'


I tried having the service return



{list:[{id:53,desc:Roberts}]}


but that didn't change anything.


More From » jquery

 Answers
226

Whats the response content-type?!
Try testing this response using this:



Getting the response content-type from jQuery.Post



also try not having the dataType: 'json' and check the return!


[#90646] Thursday, August 11, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yulissamirandah

Total Points: 493
Total Questions: 115
Total Answers: 94

Location: Lebanon
Member since Sun, Aug 2, 2020
4 Years ago
;