X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax%2Fajax.js;h=4df372bfc0ea2bce573a60491163ff47f9f08869;hb=f1c91fd023ad0bbd01a386bca4d8503e0e27df73;hp=d56ae0f1ed0d611d032e3d15604b8c70b88c2490;hpb=39c05d36493f215155cf446f7d879d3bc96ac2f7;p=jquery.git diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js index d56ae0f..4df372b 100644 --- a/src/ajax/ajax.js +++ b/src/ajax/ajax.js @@ -134,10 +134,7 @@ jQuery.fn.extend({ // If IE is used, create a wrapper for the XMLHttpRequest object if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function(){ - return new ActiveXObject( - navigator.userAgent.indexOf("MSIE 5") >= 0 ? - "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP" - ); + return new ActiveXObject("Microsoft.XMLHTTP"); }; // Attach a bunch of functions for handling common AJAX events @@ -487,6 +484,9 @@ jQuery.extend({ * (Boolean) async - By default, all requests are send asynchronous (set to true). * If you need synchronous requests, set this option to false. * + * (Function) beforeSend - A pre-callback to set custom headers etc., the + * XMLHttpRequest is passed as the only argument. + * * @example $.ajax({ * type: "GET", * url: "test.js", @@ -524,7 +524,8 @@ jQuery.extend({ data: null, contentType: "application/x-www-form-urlencoded", processData: true, - async: true + async: true, + beforeSend: null }, s); // if data available @@ -565,6 +566,10 @@ jQuery.extend({ // Make sure the browser sends the right content length if ( xml.overrideMimeType ) xml.setRequestHeader("Connection", "close"); + + // Allow custom headers/mimetypes + if( s.beforeSend ) + s.beforeSend(xml); // Wait for a response to come back var onreadystatechange = function(isTimeout){