Permalink
Browse files

jquery ajax: support for dynamic data arguments, see #2806; added tes…

…t/data/echoQuery.php for easier testing of sent query strings
  • Loading branch information...
1 parent 1753ab3 commit 46931d3146b454298231fc80a6c2d3894b125fde @jzaefferer jzaefferer committed May 6, 2008
Showing with 18 additions and 1 deletion.
  1. +1 −1 src/ajax.js
  2. +1 −0 test/data/echoQuery.php
  3. +16 −0 test/unit/ajax.js
View
@@ -489,7 +489,7 @@ jQuery.extend({
s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
});
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 s.join("&").replace(/%20/g, "+");
View
@@ -0,0 +1 @@
+<?php echo $_SERVER['QUERY_STRING']; ?>
View
@@ -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();
+ }
+ })
+});
+
}
//}

0 comments on commit 46931d3

Please sign in to comment.