Changeset 3295
- Timestamp:
- 09/15/07 01:18:30 (1 year ago)
- Location:
- trunk/jquery
- Files:
-
- 2 modified
-
src/ajax.js (modified) (3 diffs)
-
test/unit/ajax.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/jquery/src/ajax.js
r3294 r3295 164 164 s.data = jQuery.param(s.data); 165 165 166 // Break the data into one single string167 var q = s.url.indexOf("?");168 if ( q > -1 ) {169 s.data = (s.data ? s.data + "&" : "") + s.url.slice(q + 1);170 s.url = s.url.slice(0, q);171 }172 173 166 // Handle JSONP Parameter Callbacks 174 167 if ( s.dataType == "jsonp" ) { 175 if ( !s.data || !s.data.match(jsre) ) 168 if ( s.type.toLowerCase() == "get" ) { 169 if ( !s.url.match(jsre) ) 170 s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; 171 } else if ( !s.data || !s.data.match(jsre) ) 176 172 s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; 177 173 s.dataType = "json"; … … 179 175 180 176 // Build temporary JSONP function 181 if ( s.dataType == "json" && s.data && s.data.match(jsre) ) {177 if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) { 182 178 jsonp = "jsonp" + jsc++; 183 s.data = s.data.replace(jsre, "=" + jsonp); 179 180 // Replace the =? sequence both in the query string and the data 181 if ( s.data ) 182 s.data = s.data.replace(jsre, "=" + jsonp); 183 s.url = s.url.replace(jsre, "=" + jsonp); 184 184 185 185 // We need to make sure … … 202 202 203 203 if ( s.cache === false && s.type.toLowerCase() == "get" ) 204 s. data = (s.data ? s.data + "&" : "") + "_=" + (new Date()).getTime();204 s.url += (s.url.match(/\?/) ? "&" : "?") + "_=" + (new Date()).getTime(); 205 205 206 206 // If data is available, append data to url for get requests 207 207 if ( s.data && s.type.toLowerCase() == "get" ) { 208 s.url += "?"+ s.data;208 s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; 209 209 210 210 // IE likes to send both get and post data, prevent this -
trunk/jquery/test/unit/ajax.js
r3293 r3295 517 517 518 518 test("$.post(String, Hash, Function) - simple with xml", function() { 519 expect( 2);519 expect(4); 520 520 stop(); 521 521 $.post(url("data/name.php"), {xml: "5-2"}, function(xml){ 522 $('math', xml).each(function() { 523 ok( $('calculation', this).text() == '5-2', 'Check for XML' ); 524 ok( $('result', this).text() == '3', 'Check for XML' ); 525 }); 526 }); 527 528 $.post(url("data/name.php?xml=5-2"), {}, function(xml){ 522 529 $('math', xml).each(function() { 523 530 ok( $('calculation', this).text() == '5-2', 'Check for XML' );
