// Otherwise, build a param string
} else if ( typeof params === "object" ) {
- params = jQuery.param( params );
+ params = jQuery.param( params, jQuery.ajaxSettings.traditional );
type = "POST";
}
}
data: null,
username: null,
password: null,
+ traditional: false,
*/
// Create the request object; Microsoft failed to properly
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
// convert data if not already a string
if ( s.data && s.processData && typeof s.data !== "string" ) {
- s.data = jQuery.param(s.data);
+ s.data = jQuery.param( s.data, s.traditional );
}
// Handle JSONP Parameter Callbacks
}
// Wait for a response to come back
- var onreadystatechange = function( isTimeout ) {
+ var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
// The request was aborted, clear the interval and decrement jQuery.active
if ( !xhr || xhr.readyState === 0 ) {
- if ( ival ) {
- // clear poll interval
- clearInterval( ival );
- ival = null;
-
- // Handle the global AJAX counter
- if ( s.global && ! --jQuery.active ) {
- jQuery.event.trigger( "ajaxStop" );
- }
+ requestDone = true;
+ xhr.onreadystatechange = function(){};
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
}
// The transfer is complete and the data is available, or the request timed out
} else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
requestDone = true;
-
- // clear poll interval
- if (ival) {
- clearInterval(ival);
- ival = null;
- }
+ xhr.onreadystatechange = function(){};
status = isTimeout === "timeout" ?
"timeout" :
}
};
- if ( s.async ) {
- // don't attach the handler to the request, just poll it instead
- var ival = setInterval(onreadystatechange, 13);
-
- // Timeout checker
- if ( s.timeout > 0 ) {
- setTimeout(function() {
- // Check to see if the request is still happening
- if ( xhr && !requestDone ) {
- onreadystatechange( "timeout" );
- }
- }, s.timeout);
- }
+ // Timeout checker
+ if ( s.async && s.timeout > 0 ) {
+ setTimeout(function() {
+ // Check to see if the request is still happening
+ if ( xhr && !requestDone ) {
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
}
// Send the data
// Serialize an array of form elements or a set of
// key/values into a query string
- param: function( a ) {
+ param: function( a, traditional ) {
- var s = [],
-
- // Set jQuery.param.traditional to true for jQuery <= 1.3.2 behavior.
- traditional = jQuery.param.traditional;
+ var s = [];
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings.traditional;
+ }
function add( key, value ) {
// If value is a function, invoke it and return its value
});
} else {
- // If jQuery.param.traditional is true, encode the "old" way (the
- // way 1.3.2 or older did it), otherwise encode params recursively.
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
jQuery.each( a, function buildParams( prefix, obj ) {
if ( jQuery.isArray(obj) ) {