X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fajax.js;h=4db08a4dcab62bf82af503bd3315e7ff527c3c6b;hb=030ae6771533a09157347ffe1d28ee08096899da;hp=d22f1528b8a7c14f485e66a74741850d5d6ef0c0;hpb=611d24086c3837da21e0816fa3cb7b826f28da87;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index d22f152..4db08a4 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -233,9 +233,6 @@ jQuery.extend({ // If data is available, append data to url for get requests if ( s.data && type == "GET" ) { s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; - - // IE likes to send both get and post data, prevent this - s.data = null; } // Watch for a new set of requests @@ -409,7 +406,7 @@ jQuery.extend({ // Send the data try { - xhr.send(s.data); + xhr.send( type === "POST" ? s.data : null ); } catch(e) { jQuery.handleError(s, xhr, null, e); } @@ -484,24 +481,32 @@ jQuery.extend({ xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, data = xml ? xhr.responseXML : xhr.responseText; - if ( xml && data.documentElement.tagName == "parsererror" ) + if ( xml && data.documentElement.tagName == "parsererror" ) { throw "parsererror"; + } // Allow a pre-filtering function to sanitize the response // s != null is checked to keep backwards compatibility - if( s && s.dataFilter ) + if ( s && s.dataFilter ) { data = s.dataFilter( data, type ); + } // The filter can actually parse the response - if( typeof data === "string" ){ + if ( typeof data === "string" ) { // If the type is "script", eval it in global context - if ( type == "script" ) + if ( type === "script" ) { jQuery.globalEval( data ); + } // Get the JavaScript object, if JSON is used. - if ( type == "json" ) - data = window["eval"]("(" + data + ")"); + if ( type == "json" ) { + if ( typeof JSON === "object" && JSON.parse ) { + data = JSON.parse( data ); + } else { + data = (new Function("return " + data))(); + } + } } return data;