return this.find('script').each(function(){
if ( this.src )
// for some weird reason, it doesn't work if the callback is ommited
- jQuery.getScript( this.src, function() {} );
- else
- eval.call( window, this.text || this.textContent || this.innerHTML || "" );
+ jQuery.getScript( this.src );
+ else {
+ jQuery.eval ( this.text || this.textContent || this.innerHTML || "" );
+ }
}).end();
}
* 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.
*
if ( s.ifModified && modRes )
jQuery.lastModified[s.url] = modRes;
- // If a local callback was specified, fire it
+ // process the data (runs the xml through httpData regardless of callback)
+ var data = jQuery.httpData( xml, s.dataType );
+
+ // If a local callback was specified, fire it and pass it the data
if ( s.success )
- s.success( jQuery.httpData( xml, s.dataType ), status );
+ s.success( data, status );
// Fire the global callback
if( s.global )
var data = !type && ct && ct.indexOf("xml") >= 0;
data = type == "xml" || data ? r.responseXML : r.responseText;
- // If the type is "script", eval it
- if ( type == "script" ) eval.call( window, data );
+ // If the type is "script", eval it in global context
+ if ( type == "script" ) {
+ jQuery.eval( data );
+ }
// Get the JavaScript object, if JSON is used.
if ( type == "json" ) eval( "data = " + data );
} 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] ) );
// Return the resulting serialization
return s.join("&");
+ },
+
+ // TODO document me
+ eval: function(data) {
+ if (window.execScript)
+ window.execScript( data );
+ else
+ eval.call( window, data );
}
});