Skip to main content

Bug Tracker

Side navigation

#7924 closed bug (worksforme)

Opened January 07, 2011 11:55PM UTC

Closed January 08, 2011 12:30AM UTC

Last modified March 10, 2012 11:43AM UTC

JSON name collision when using jQuery.ajax()

Reported by: jhill9693@gmail.com Owned by:
Priority: undecided Milestone: 1.next
Component: ajax Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

Version: jQuery 1.4.2

Browser: Firefox 3.6.13 with Firebug 1.6.1

OS: Windows 7 Home Premium, x64

Steps to reproduce:

1. Set up a server-side handler to send the following JSON data:

{"result":"success"}

2. Perform a jQuery.ajax() call:

$.ajax({
    cache: false,
    type:  'POST',
    url:   'http://url-to-your-application',
    data:  {},
    dataType: 'json',
    error: function(e, xhr) {
        alert('error');
    }
    success: function(data, textStatus, XMLHttpRequest) {
        alert('success');
    }
});

Expected result:

An alert box with the word 'success'

Actual result:

An alert box with the word 'error'

Workaround:

The "result" property in the JSON object seems to be the problem. Changing it to "r" allows jQuery to parse the JSON correctly.

Attachments (0)
Change History (3)

Changed January 08, 2011 12:29AM UTC by jitter comment:1

_comment0: Thanks for taking the time to contribute to the jQuery project by writing a bug report. As you didn't provide a live test case on http://jsfiddle.net I made one my self. [http://jsfiddle.net/jitter/h4DQw/ live test case] but I couldn't reproduce your problem. \ \ Please report back if you can provide a reproducible test case and request the reopening of this ticket and we will happily investigate this issue further. \ ----- \ [http://docs.jquery.com/How_to_Report_Bugs How to report bugs]1294446598053765
component: unfiledajax
resolution: → invalid
status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report. As you didn't provide a live test case on http://jsfiddle.net I made one my self. live test case but I couldn't reproduce your problem with the current jQuery version (1.4.4).

Please report back if you can provide a reproducible test case and request the reopening of this ticket and we will happily investigate this issue further.


How to report bugs

Changed January 08, 2011 12:30AM UTC by jitter comment:2

resolution: invalid
status: closedreopened

Changed January 08, 2011 12:30AM UTC by jitter comment:3

resolution: → worksforme
status: reopenedclosed