aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ajax.js2
-rw-r--r--test/data/echoQuery.php1
-rw-r--r--test/unit/ajax.js16
3 files changed, 18 insertions, 1 deletions
diff --git a/src/ajax.js b/src/ajax.js
index b089f22c2..b90ca16cb 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -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, "+");
diff --git a/test/data/echoQuery.php b/test/data/echoQuery.php
new file mode 100644
index 000000000..b72f329c9
--- /dev/null
+++ b/test/data/echoQuery.php
@@ -0,0 +1 @@
+<?php echo $_SERVER['QUERY_STRING']; ?> \ No newline at end of file
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index c8bf2ce4b..a5891c53e 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -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();
+ }
+ })
+});
+
}
//}