Jquery 1.5.2 & Json
I upgraded my Jquery from 1.3.2 to 1.5.2 and all of a sudden my $.ajax{} calls stopped working:
It looked something like this:
$.ajax({
type: "POST",
url: "URL",
data: "date id : date param",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
handle(data.d)
},
error: function error(jqXHR, textStatus, errorThrown) {
console.log("jqXHR: " + jqXHR + "\n" + "Text Status: " + textStatus + "\n" + "Error Thrown: " + errorThrown);
}
});
The error I got was:
jqXHR: [object Object]
Text Status: parsererror Error Thrown:
jQuery152012837810831775243_1302731642482 was not called
invalid label {"d":"\u003c?xml version=\"1.0\" ncod...r\n\u003c/ArrayOfFutureBooking\u003e"}
After a day of reading about $.ajax and json, I found that jQuery’s Validation plug-in is not compatible with jQuery 1.5. However after updating jquery.validation I still got the
invalid label
error. I did find an alternate solution, it feels a bit hacky, but works tho!
In the jquery1.5.2.js find the line:
d.ajaxPrefilter("json jsonp", function (b, c, e)
and change to
d.ajaxPrefilter("jsonp", function (b, c, e)
That works, and all of my $.ajax functions are happy again.
No trackbacks yet.