Bug Tracker

Modify

Ticket #8697 (closed bug: duplicate)

Opened 2 years ago

Last modified 2 years ago

$.ajax fails when data contains '??'

Reported by: stuart.turner@… Owned by:
Priority: undecided Milestone: 1.next
Component: ajax Version: 1.5
Keywords: Cc:
Blocking: Blocked by:

Description

Example code:

var js = JSON.stringify({ note: 'questions?? more information' });
$.ajax({
    data: js,
    dataType: "json",
    success: function (data) { }
    error: function (XMLHttpRequest, textStatus, errorThrown) { }
});

I believe that the issue lies in ajaxPrefilter. The jsre is too aggressive and matches the first '??' it finds anywhere in the data string. The '??' gets replaced w/ an anonymous callback function name, such that the server receives the note field as:

    questionsjQuery<anonymous numbering> more information

On return from the server, the ajax call cannot find the anonymous function and goes straight to the error handling instead of calling the success function.

Change History

comment:1 Changed 2 years ago by stuart.turner@…

I apologize for not using jsFiddle. Here is a test case:  http://jsfiddle.net/R5g7C/

comment:2 Changed 2 years ago by timmywil

Confirmed and validated json,  http://jsfiddle.net/timmywil/R5g7C/3/

And switched to jQuery(edge)

Last edited 2 years ago by timmywil (previous) (diff)

comment:3 Changed 2 years ago by jaubourg

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

comment:4 Changed 2 years ago by jaubourg

Duplicate of #8417.

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.