X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=src%2Fajax.js;h=885c8193e03341c37583d548b97d26be5b05b0c3;hb=c66aa570299459ea948eb123a442da6e22a9611b;hp=42d0b280ca41478cc7f2f81acba382d69a2a50f4;hpb=335b8816c2f1e66de1fa245278794f8c7fdb1e01;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index 42d0b28..885c819 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -97,6 +97,7 @@ jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".sp var jsc = now(); jQuery.extend({ + get: function( url, data, callback, type ) { // shift arguments if data argument was ommited if ( jQuery.isFunction( data ) ) { @@ -151,6 +152,12 @@ jQuery.extend({ data: null, username: null, password: null, + // Create the request object; Microsoft failed to properly + // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available + // This function can be overriden by calling jQuery.ajaxSetup + xhr:function(){ + return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); + }, accepts: { xml: "application/xml, text/xml", html: "text/html", @@ -273,9 +280,8 @@ jQuery.extend({ var requestDone = false; - // Create the request object; Microsoft failed to properly - // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available - var xhr = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); + // Create the request object + var xhr = s.xhr(); // Open the socket // Passing null username, generates a login popup on Opera (#2865) @@ -470,17 +476,22 @@ jQuery.extend({ throw "parsererror"; // Allow a pre-filtering function to sanitize the response - if( s.dataFilter ) + // s != null is checked to keep backwards compatibility + if( s && s.dataFilter ) data = s.dataFilter( data, type ); - // If the type is "script", eval it in global context - if ( type == "script" ) - jQuery.globalEval( data ); + // The filter can actually parse the response + if( typeof data == 'string' ){ - // Get the JavaScript object, if JSON is used. - if ( type == "json" ) - data = eval("(" + data + ")"); + // If the type is "script", eval it in global context + if ( type == "script" ) + jQuery.globalEval( data ); + // Get the JavaScript object, if JSON is used. + if ( type == "json" ) + data = eval("(" + data + ")"); + } + return data; },