Welcome Guest, Not a member yet? Register   Sign In
[FIX] [UPDATE] jQuery 1.5 breaks AJAX with CodeIgniter and JSON
#1

[eluser]intractve[/eluser]
Spent quite a bit of time debugging my application after I found, all ajax calls were failing (404) on my app, after upgrading to the latest stable jQuery build 1.5.

I almost exclusively use JSON to transport my data via ajax and jQuery has introduced a bug/feature (depends on your viewpoint) where all JSON requests are treated as JSONP

All JSON requests via $.getJSON or $.ajax with a type specified as json will attach the callback querystring, forcing CI to return a 404 if you do not use query strings.

The Fix
Code:
//Add the following to the end of your jquery.js file

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

There is a drawback to this method By default, it will break all jsonp requests unless you override them when you create the call.

The official bugtracker for jQuery lists this as "wontfix" meaning they call it a feature.
Here's the link if you want to read more:
jQuery Bug Tracker

Update!
Further reading pointed me to http://bugs.jquery.com/ticket/8064

Where it is said it is possible jQuery.validate an excellent validation plugin could be the culprit
and a link to a forked version of the plugin with a fix is posted.
#2

[eluser]stormbytes[/eluser]
I was having this same exact problem. $.get() requests containing a JSON object are producing an error (missing required argument - to function). This didn't fix the problem and so the jury's still out, though I kind of figured it had something to do with query strings




Theme © iAndrew 2016 - Forum software by © MyBB