Skip to content
Browse files

Fixes #8277. Sets data to undefined rather than null when it is not p…

…rovided in ajax helpers so that it won't revent data set in ajaxSettings from being used. Unit test added.
  • Loading branch information...
1 parent 8e40a84 commit 1ddfdabbb983e2d3bf7f7200a3da5051f274e6fe @jaubourg jaubourg committed Feb 15, 2011
Showing with 18 additions and 3 deletions.
  1. +3 −3 src/ajax.js
  2. +15 −0 test/unit/ajax.js
View
6 src/ajax.js
@@ -164,7 +164,7 @@ jQuery.fn.extend({
if ( jQuery.isFunction( params ) ) {
// We assume that it's the callback
callback = params;
- params = null;
+ params = undefined;
// Otherwise, build a param string
} else if ( typeof params === "object" ) {
@@ -256,7 +256,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
if ( jQuery.isFunction( data ) ) {
type = type || callback;
callback = data;
- data = null;
+ data = undefined;
}
return jQuery.ajax({
@@ -272,7 +272,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
jQuery.extend({
getScript: function( url, callback ) {
- return jQuery.get( url, null, callback, "script" );
+ return jQuery.get( url, undefined, callback, "script" );
},
getJSON: function( url, data, callback ) {
View
15 test/unit/ajax.js
@@ -1196,6 +1196,21 @@ test("load(String, String, Function)", function() {
});
});
+test("jQuery.get(String, Function) - data in ajaxSettings (#8277)", function() {
+ expect(1);
+ stop();
+ jQuery.ajaxSetup({
+ data: "helloworld"
+ });
+ jQuery.get(url('data/echoQuery.php'), function(data) {
+ ok( /helloworld$/.test( data ), 'Data from ajaxSettings was used');
+ jQuery.ajaxSetup({
+ data: null
+ });
+ start();
+ });
+});
+
test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
expect(2);
stop();

0 comments on commit 1ddfdab

Please sign in to comment.
Something went wrong with that request. Please try again.