#7924 closed bug (worksforme)
JSON name collision when using jQuery.ajax()
Reported by: | 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:
- 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 (3)
comment:1 Changed 13 years ago by
Component: | unfiled → ajax |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Version 0, edited 13 years ago
by
(next)
comment:2 Changed 13 years ago by
Resolution: | invalid |
---|---|
Status: | closed → reopened |
comment:3 Changed 13 years ago by
Resolution: | → worksforme |
---|---|
Status: | reopened → closed |
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.
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