X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fajax%2Fajax.js;h=d72ddc6b7351b4323c5864b5711f7b2069074775;hb=78db847ef201a66f88e9ad330b2e51c65c58abb3;hp=51457d0a733f72a13020c5c9a17978eef5f9ddc8;hpb=3e165ae5ab080236eb0df35c691d6f3127c6499e;p=jquery.git
diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js
index 51457d0..d72ddc6 100644
--- a/src/ajax/ajax.js
+++ b/src/ajax/ajax.js
@@ -4,16 +4,16 @@ jQuery.fn.extend({
* Load HTML from a remote file and inject it into the DOM, only if it's
* been modified by the server.
*
- * @example $("#feeds").loadIfModified("feeds.html")
+ * @example $("#feeds").loadIfModified("feeds.html");
* @before
").html(data).evalScripts();
+ if ( type == "html" )
+ jQuery("
").html(data).evalScripts();
return data;
},
// Serialize an array of form elements or a set of
// key/values into a query string
- param: function(a) {
+ param: function( a ) {
var s = [];
// If an array was passed in, assume that it is an array
// of form elements
- if ( a.constructor == Array || a.jquery ) {
+ if ( a.constructor == Array || a.jquery )
// Serialize the form elements
- for ( var i = 0; i < a.length; i++ )
- s.push( a[i].name + "=" + encodeURIComponent( a[i].value ) );
+ jQuery.each( a, function(){
+ s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
+ });
// Otherwise, assume that it's an object of key/value pairs
- } else {
+ else
// Serialize the key/values
- for ( var j in a ) {
+ for ( var j in a )
// 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] ) );
- }
- } else {
- s.push( j + "=" + encodeURIComponent( a[j] ) );
- }
- }
- }
+ if ( a[j] && a[j].constructor == Array )
+ jQuery.each( a[j], function(){
+ s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
+ });
+ else
+ s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );
// Return the resulting serialization
return s.join("&");
@@ -766,14 +827,17 @@ jQuery.extend({
// evalulates a script in global context
// not reliable for safari
- globalEval: function(data) {
- if (window.execScript)
- window.execScript( data );
- else if(jQuery.browser.safari)
- // safari doesn't provide a synchronous global eval
- window.setTimeout( data, 0 );
- else
- eval.call( window, data );
+ globalEval: function( data ) {
+ data = jQuery.trim( data );
+ if ( data ) {
+ if ( window.execScript )
+ window.execScript( data );
+ else if ( jQuery.browser.safari )
+ // safari doesn't provide a synchronous global eval
+ window.setTimeout( data, 0 );
+ else
+ eval.call( window, data );
+ }
}
});