Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#8277 closed bug (fixed)

Default data, setuped via ajaxSetup do not send in get and load functions, if use callback function.

Reported by: whitefur@… Owned by: jaubourg
Priority: high Milestone: 1.5.1
Component: ajax Version: 1.5
Keywords: Cc: jaubourg
Blocked by: Blocking:


If set default data via ajaxSetup() For example

 data : {'kid' : 'mike'}

And then use load('url',callback) , whith callback, data do not send to the server.

If use load('url') - All works correctly. Same bug in get function....

In both functions, if second argument is a callback function, jQuery set data param to NULL value, and then it value rewrite default ajaxSettings.data in extend() function. Correctly use UNDEFINED value, because in extend() fucntion use hard type hinting ...

} else if ( copy !== undefined ) {
 target[ name ] = copy;

.... Actually both for version 1.5, and for version 1.4

Change History (3)

comment:1 Changed 6 years ago by jitter

Cc: jaubourg added
Component: unfiledajax
Milestone: 1.next1.5.1
Priority: undecidedhigh
Status: newopen

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

test case

It seems like most of the ajax shorthand functions are affected by this since 1.4 . As the reporter pointed out this happens because the utility functions set data to null when the second parameter is a function.

Affected functions: .get/.post/.load (.getJSON / .getScript too because they use .get internally)

Offending lines are https://github.com/jquery/jquery/blob/1.5/src/ajax.js#L232 and https://github.com/jquery/jquery/blob/1.5/src/ajax.js#L140

comment:2 Changed 6 years ago by jaubourg

Owner: set to jaubourg
Status: openassigned

comment:3 Changed 6 years ago by jaubourg

Resolution: fixed
Status: assignedclosed

Fixes #8277. Sets data to undefined rather than null when it is not provided in ajax helpers so that it won't revent data set in ajaxSettings from being used. Unit test added.

Changeset: 1ddfdabbb983e2d3bf7f7200a3da5051f274e6fe

Note: See TracTickets for help on using tickets.