X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax%2Fajax.js;h=f0f448aa1d66b3207decdf02bb883fd4f77a7820;hb=a2ab7ef088046c8e3af7e38dabb8746050e97396;hp=efd7ae2caed2e7462fb4c824db12df2405001fb5;hpb=15a30ba90cb4ff46ea17e775dd20f38f3c07e112;p=jquery.git diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js index efd7ae2..f0f448a 100644 --- a/src/ajax/ajax.js +++ b/src/ajax/ajax.js @@ -124,12 +124,7 @@ jQuery.fn.extend({ // for some weird reason, it doesn't work if the callback is ommited jQuery.getScript( this.src ); else { - // TODO extract into $.eval - var data = this.text || this.textContent || this.innerHTML || ""; - if (window.execScript) - window.execScript( data ); - else - window.setTimeout( data, 0 ); + jQuery.eval ( this.text || this.textContent || this.innerHTML || "" ); } }).end(); } @@ -687,13 +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 - // TODO extract as $.eval + // 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. @@ -734,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 ); } });