mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
jquery ajax: support for dynamic data arguments, see #2806; added test/data/echoQuery.php for easier testing of sent query strings
This commit is contained in:
parent
1753ab3d82
commit
46931d3146
@ -489,7 +489,7 @@ jQuery.extend({
|
|||||||
s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
|
s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
|
||||||
});
|
});
|
||||||
else
|
else
|
||||||
s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );
|
s.push( encodeURIComponent(j) + "=" + encodeURIComponent( jQuery.isFunction(a[j]) ? a[j]() : a[j] ) );
|
||||||
|
|
||||||
// Return the resulting serialization
|
// Return the resulting serialization
|
||||||
return s.join("&").replace(/%20/g, "+");
|
return s.join("&").replace(/%20/g, "+");
|
||||||
|
1
test/data/echoQuery.php
Normal file
1
test/data/echoQuery.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?php echo $_SERVER['QUERY_STRING']; ?>
|
@ -811,6 +811,22 @@ test("custom timeout does not set error message when timeout occurs, see #970",
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("data option: evaluate function values (#2806)", function() {
|
||||||
|
stop();
|
||||||
|
$.ajax({
|
||||||
|
url: "data/echoQuery.php",
|
||||||
|
data: {
|
||||||
|
key: function() {
|
||||||
|
return "value";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: function(result) {
|
||||||
|
equals( result, "key=value" );
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
Loading…
Reference in New Issue
Block a user