you want this... I want that... perhaps if we had a pre-ajax callback where we can massage the req (at about the same place as your patch).. we both could be happy and this will probably handle lots of future requirements.
I wanted overrideMimeType for files served as text/html but requested as type xml. On 12/4/06, Kelvin Luck <[EMAIL PROTECTED]> wrote:
Hi, I'm just working on a project which is making ajax calls to a .NET backend using the AjaxPro extension. However, since I'm already using jQuery on the front end I thought I'd avoid using their extra frontend code and just use jQuery. The problem is that their .NET backend expects a custom header ('X-AjaxPro-Method' with the name of the server side method you want to call) which jQuery doesn't seem to support natively. So I made the attached little patch (against jquery-1.0.3.js [Rev: 501]) which just allows you to pass extra headers to the ajax call. It seems to be working for me - please consider it for inclusion into jQuery, Cheers, Kelvin :) Index: jquery-1.0.3.js =================================================================== --- jquery-1.0.3.js (revision 21) +++ jquery-1.0.3.js (working copy) @@ -1762,7 +1762,7 @@ // Last-Modified header cache for next request lastModified: {}, - ajax: function( type, url, data, ret, ifModified ) { + ajax: function( type, url, data, ret, ifModified, headers ) { // If only a single argument was passed in, // assume that it is a object of key/value pairs var global = true; @@ -1777,6 +1777,7 @@ ifModified = type.ifModified || false; data = type.data; url = type.url; + headers = type.headers; type = type.type; } @@ -1804,6 +1805,12 @@ // Set header so the called script knows that it's an XMLHttpRequest xml.setRequestHeader("X-Requested-With", "XMLHttpRequest"); + if (headers) { + for (header in headers) { + xml.setRequestHeader(header, headers[header]); + } + } + // Make sure the browser sends the right content length if ( xml.overrideMimeType ) xml.setRequestHeader("Connection", "close"); _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
-- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/