Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery 1.5 and new "Text JSON" datatype

Tags:

jquery

I have just updated to JQuery 1.5 and all my ajax calls that return JSON and a number of plugins instantly broke.

In my pre-1.5 code, I specified the dataType like:

dataType: "json"

Changing the dataType to:

dataType: "text json"

Fixes the problem but I do not want to manually change the plugins as this will affect upgrades.

Is there a way of handling this better with less disruption?

like image 592
dagda1 Avatar asked Feb 10 '11 09:02

dagda1


2 Answers

This problem is caused by the jQuery validation plugin and how it extends the ajaxSettings object for its own use (changes json calls to jsonp calls). There will hopefully be an official update to the validation plugin soon, but in the meantime, there's a patch available here that fixes the problem:

https://github.com/bigfix/jquery-validation/commit/9aa53f9241224ba349f9fe1b2c801be0f431b63b

Edit:

jQuery Validation Plugin, compatible with jQuery 1.5.1, available on git hub: https://github.com/jzaefferer/jquery-validation

Edit #2: jQuery Validation Plugin 1.8, compatible with jQuery 1.5.1 (and earlier) is released:

Read about it: http://bassistance.de/2011/03/25/release-validation-plugin-1-8/

Download it: http://bassistance.de/jquery-plugins/jquery-plugin-validation/

like image 175
James H Avatar answered Nov 18 '22 12:11

James H


I came across this JQuery bug which fixes the problem http://bugs.jquery.com/ticket/8084.

Adding the following code after the JQuery script declaration fixes the problem:

$.ajaxSetup({ jsonp: null, jsonpCallback: null });

like image 4
dagda1 Avatar answered Nov 18 '22 11:11

dagda1