#8277 closed bug (fixed)
Default data, setuped via ajaxSetup do not send in get and load functions, if use callback function.
Reported by: | 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
Change History (3)
comment:1 Changed 12 years ago by
Cc: | jaubourg added |
---|---|
Component: | unfiled → ajax |
Milestone: | 1.next → 1.5.1 |
Priority: | undecided → high |
Status: | new → open |
comment:2 Changed 12 years ago by
Owner: | set to jaubourg |
---|---|
Status: | open → assigned |
comment:3 Changed 12 years ago by
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