views:

22

answers:

1

Hey,

I have just updated to 1.4.2 and now everything that has worked before does not. And I cant figure out why.

var data = {
    'what': 'post',
    'type': $(this).attr('class'),
    'id': $(this).next('input').val()
}

$.post(
'/utils/ajax/', 
    data, 
    function(response) {
        alert(response.result);

    }, 'json'
);

It looks like now (after the update) I wont even get to the success function, although firebug says that everything was fine and shows the returned string. If that will help I am using django.

Any ideas are appreciated

Regards

+2  A: 

Your problem is probably that JSON goes through much stricter validation in jQuery 1.4+, your JSON response must be valid, or it will silently fail. Check the response coming from the server here to make sure it's valid:

http://www.jsonlint.com/

If that's not the case...when you resolve the issue and generate valid JSON, your success function will work again :)

Nick Craver
Agreed - the single quotes are breaking it
Mike Robinson
@Mike - Oh he's just creating an object there, that should be ok (it gets serialized anyway)...the server response I'm betting isn't though :)
Nick Craver
It worked when I changed (in the django part) ' to ". Guys? Whats the difference? lol
realshadow
It's a strict interpretation of JSON. Server-side ' can represent character, while " represents string. Big difference there, and if jQuery is following strict that'd explain it.
Mike Robinson