Skip to main content

Bug Tracker

Side navigation

#8277 closed bug (fixed)

Opened February 15, 2011 09:29AM UTC

Closed February 15, 2011 08:55PM UTC

Last modified March 09, 2012 11:27AM UTC

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

Reported by: whitefur@mail.ru Owned by: jaubourg
Priority: high Milestone: 1.5.1
Component: ajax Version: 1.5
Keywords: Cc: jaubourg
Blocked by: Blocking:
Description

If set default data via ajaxSetup()

For example

$.ajaxSetup({
 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

Attachments (0)
Change History (3)

Changed February 15, 2011 12:25PM UTC by jitter comment:1

cc: → jaubourg
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

Changed February 15, 2011 08:46PM UTC by jaubourg comment:2

owner: → jaubourg
status: openassigned

Changed February 15, 2011 08:55PM UTC by jaubourg comment:3

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