aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-07-19 19:03:18 +0000
committerJohn Resig <jeresig@gmail.com>2009-07-19 19:03:18 +0000
commitfa2d66363928ec6f6b615b9e5e5d9ab002651457 (patch)
tree809aeefde20d1e4f4fbe7fa9c4ebf742a47ec73f /src
parent81985c7878db2dd4dc31a3a9f8028eaae314ec24 (diff)
downloadjquery-fa2d66363928ec6f6b615b9e5e5d9ab002651457.tar.gz
jquery-fa2d66363928ec6f6b615b9e5e5d9ab002651457.zip
Did some cleaning up of ajax.js and fixed a bug from commit [6457].
Diffstat (limited to 'src')
-rw-r--r--src/ajax.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/ajax.js b/src/ajax.js
index fe272e78f..35bb008dc 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -177,20 +177,23 @@ jQuery.extend({
// checked again later (in the test suite, specifically)
s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
- var jsonp, jsre = /=\?(&|$)/g, status, data,
+ var jsonp, jsre = /=\?(&|$)/, status, data,
type = s.type.toUpperCase();
// convert data if not already a string
- if ( s.data && s.processData && typeof s.data !== "string" )
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
s.data = jQuery.param(s.data);
+ }
// Handle JSONP Parameter Callbacks
if ( s.dataType == "jsonp" ) {
if ( type == "GET" ) {
- if ( !jsre.test( s.url ) )
+ if ( !jsre.test( s.url ) ) {
s.url += (/\?/.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
- } else if ( !s.data || !jsre.test(s.data) )
+ }
+ } else if ( !s.data || !jsre.test(s.data) ) {
s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ }
s.dataType = "json";
}
@@ -199,8 +202,10 @@ jQuery.extend({
jsonp = "jsonp" + jsc++;
// Replace the =? sequence both in the query string and the data
- if ( s.data )
+ if ( s.data ) {
s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ }
+
s.url = s.url.replace(jsre, "=" + jsonp + "$1");
// We need to make sure