X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fajax%2Fajax.js;h=73eba22b15f4774c9ed1348c473ed9c6fa7eb41b;hb=ef1ee513d314123017fce770e8fe0a9c85b9eb87;hp=b8ccdd65220e210a0cfb3d5fa9d30156c15f1a11;hpb=46faa03820f82e5b03e6b3d73bd9d5b194b2b310;p=jquery.git diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js index b8ccdd6..73eba22 100644 --- a/src/ajax/ajax.js +++ b/src/ajax/ajax.js @@ -123,8 +123,9 @@ jQuery.fn.extend({ if ( this.src ) // for some weird reason, it doesn't work if the callback is ommited jQuery.getScript( this.src ); - else - eval.call( window, this.text || this.textContent || this.innerHTML || "" ); + else { + jQuery.eval ( this.text || this.textContent || this.innerHTML || "" ); + } }).end(); } @@ -467,7 +468,7 @@ jQuery.extend({ * function gets passed two arguments: The XMLHttpRequest object and a * string describing the type the success of the request. * - * (String) data - Data to be sent to the server. Converted to a query + * (Object|String) data - Data to be sent to the server. Converted to a query * string, if not already a string. Is appended to the url for GET-requests. * Override processData option to prevent processing. * @@ -681,12 +682,9 @@ jQuery.extend({ var data = !type && ct && ct.indexOf("xml") >= 0; data = type == "xml" || data ? r.responseXML : r.responseText; - // If the type is "script", eval it´in global context + // If the type is "script", eval it in global context if ( type == "script" ) { - if (window.execScript) - window.execScript( data ); - else - window.setTimeout( data, 0 ); + jQuery.eval( data ); } // Get the JavaScript object, if JSON is used. @@ -714,10 +712,10 @@ jQuery.extend({ } else { // Serialize the key/values for ( var j in a ) { - //if one value is array then treat each array value in part - if (typeof a[j] == 'object') { + // If the value is an array then the key names need to be repeated + if( a[j].constructor == Array ) { for (var k = 0; k < a[j].length; k++) { - s.push( j + "[]=" + encodeURIComponent( a[j][k] ) ); + s.push( j + "=" + encodeURIComponent( a[j][k] ) ); } } else { s.push( j + "=" + encodeURIComponent( a[j] ) ); @@ -727,6 +725,14 @@ jQuery.extend({ // Return the resulting serialization return s.join("&"); + }, + + // TODO document me + eval: function(data) { + if (window.execScript) + window.execScript( data ); + else + eval.call( window, data ); } });