Bug Tracker

Modify

Ticket #7924 (closed bug: worksforme)

Opened 3 years ago

Last modified 2 years ago

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:

  1. Set up a server-side handler to send the following JSON data:
{"result":"success"}
  1. 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

comment:1 Changed 3 years ago by jitter

  • Status changed from new to closed
  • Resolution set to invalid
  • Component changed from unfiled to ajax

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

Version 0, edited 3 years ago by jitter (next)

comment:2 Changed 3 years ago by jitter

  • Status changed from closed to reopened
  • Resolution invalid deleted

comment:3 Changed 3 years ago by jitter

  • Status changed from reopened to closed
  • Resolution set to worksforme

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.