Commit 26150f09 authored by George Mauer's avatar George Mauer Committed by Dave Methvin

Ajax: $.post and $.get can now take an options object

Fixes gh-1986
Closes gh-1995
(cherry picked from commit 89ce0af2cf7f001647e74fc1de92ce94a51fd5c2)
parent 07719736
...@@ -798,13 +798,14 @@ jQuery.each( [ "get", "post" ], function( i, method ) { ...@@ -798,13 +798,14 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
data = undefined; data = undefined;
} }
return jQuery.ajax({ // The url can be an options object (which then must have .url)
return jQuery.ajax( jQuery.extend({
url: url, url: url,
type: method, type: method,
dataType: type, dataType: type,
data: data, data: data,
success: callback success: callback
}); }, jQuery.isPlainObject( url ) && url ) );
}; };
}); });
......
...@@ -2050,6 +2050,26 @@ module( "ajax", { ...@@ -2050,6 +2050,26 @@ module( "ajax", {
}); });
}); });
asyncTest( "jQuery[get|post]( options ) - simple with xml", 2, function() {
jQuery.when.apply( jQuery,
jQuery.map( [ "get", "post" ] , function( method ) {
return jQuery[ method ]({
url: url( "data/name.php" ),
data: {
"xml": "5-2"
},
success: function( xml ) {
jQuery( "math", xml ).each(function() {
strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" );
});
}
});
})
).always(function() {
start();
});
});
//----------- jQuery.active //----------- jQuery.active
test( "jQuery.active", 1, function() { test( "jQuery.active", 1, function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment