Bug Tracker

Opened 13 years ago

Closed 13 years ago

#1638 closed bug (fixed)

Error migrating some $.ajax(...) calls to version 1.2.x (from versions 1.1.x)

Reported by: Piatenko Owned by:
Priority: major Milestone: 1.2.2
Component: ajax Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:

Description

Prior to version 1.2 it was ok to pass a Number data parameter to jQuery.ajax() function. Example:

var i = 321;
$.ajax( { url: "/test.html", type:"POST", dataType:"json", data: i,
processData:false, success:function(r){alert(r)} } )

in new version I have to specify data: i+"" to pass it as string parameter

var i = 321;
$.ajax( { url: "/test.html", type:"POST", dataType:"json", data: i+"",
processData:false, success:function(r){alert(r)} } )

and that's only because of this new line 2216 in code (v 1.2.1):

if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {

it could be easily fixed by adding only one additional condition typeof s.data==="string" here:

if ( s.dataType == "json" && (s.data && typeof s.data==="string" && s.data.match(jsre) ||
s.url.match(jsre)) ) {

Change History (1)

comment:1 Changed 13 years ago by john

Milestone: 1.2.11.2.2
Resolution: fixed
Status: newclosed
Version: 1.21.2.1

Fixed in SVN rev [3670].

Note: See TracTickets for help on using tickets.