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:

    type: "POST",
    url: "URL",
    data: "date id : date param",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {
    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.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: