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 comment:1
cc: | → jaubourg |
---|---|
component: | unfiled → ajax |
milestone: | 1.next → 1.5.1 |
priority: | undecided → high |
status: | new → open |
Changed February 15, 2011 08:46PM UTC by comment:2
owner: | → jaubourg |
---|---|
status: | open → assigned |
Changed February 15, 2011 08:55PM UTC by comment:3
resolution: | → fixed |
---|---|
status: | assigned → closed |
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
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
tonull
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