Modify ↓
Ticket #7924 (closed bug: worksforme)
JSON name collision when using jQuery.ajax()
| Reported by: | jhill9693@… | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.next |
| Component: | ajax | Version: | 1.4.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
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:
- Set up a server-side handler to send the following JSON data:
{"result":"success"}
- 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.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

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