@@ 10464-10540 (lines=77) @@ | ||
10461 | } ); |
|
10462 | ||
10463 | // Detect, normalize options and install callbacks for jsonp requests |
|
10464 | jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
|
10465 | ||
10466 | var callbackName, overwritten, responseContainer, |
|
10467 | jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? |
|
10468 | "url" : |
|
10469 | typeof s.data === "string" && |
|
10470 | ( s.contentType || "" ) |
|
10471 | .indexOf( "application/x-www-form-urlencoded" ) === 0 && |
|
10472 | rjsonp.test( s.data ) && "data" |
|
10473 | ); |
|
10474 | ||
10475 | // Handle iff the expected data type is "jsonp" or we have a parameter to set |
|
10476 | if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { |
|
10477 | ||
10478 | // Get callback name, remembering preexisting value associated with it |
|
10479 | callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? |
|
10480 | s.jsonpCallback() : |
|
10481 | s.jsonpCallback; |
|
10482 | ||
10483 | // Insert callback into url or form data |
|
10484 | if ( jsonProp ) { |
|
10485 | s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); |
|
10486 | } else if ( s.jsonp !== false ) { |
|
10487 | s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; |
|
10488 | } |
|
10489 | ||
10490 | // Use data converter to retrieve json after script execution |
|
10491 | s.converters[ "script json" ] = function() { |
|
10492 | if ( !responseContainer ) { |
|
10493 | jQuery.error( callbackName + " was not called" ); |
|
10494 | } |
|
10495 | return responseContainer[ 0 ]; |
|
10496 | }; |
|
10497 | ||
10498 | // force json dataType |
|
10499 | s.dataTypes[ 0 ] = "json"; |
|
10500 | ||
10501 | // Install callback |
|
10502 | overwritten = window[ callbackName ]; |
|
10503 | window[ callbackName ] = function() { |
|
10504 | responseContainer = arguments; |
|
10505 | }; |
|
10506 | ||
10507 | // Clean-up function (fires after converters) |
|
10508 | jqXHR.always( function() { |
|
10509 | ||
10510 | // If previous value didn't exist - remove it |
|
10511 | if ( overwritten === undefined ) { |
|
10512 | jQuery( window ).removeProp( callbackName ); |
|
10513 | ||
10514 | // Otherwise restore preexisting value |
|
10515 | } else { |
|
10516 | window[ callbackName ] = overwritten; |
|
10517 | } |
|
10518 | ||
10519 | // Save back as free |
|
10520 | if ( s[ callbackName ] ) { |
|
10521 | ||
10522 | // make sure that re-using the options doesn't screw things around |
|
10523 | s.jsonpCallback = originalSettings.jsonpCallback; |
|
10524 | ||
10525 | // save the callback name for future use |
|
10526 | oldCallbacks.push( callbackName ); |
|
10527 | } |
|
10528 | ||
10529 | // Call if it was a function and we have a response |
|
10530 | if ( responseContainer && jQuery.isFunction( overwritten ) ) { |
|
10531 | overwritten( responseContainer[ 0 ] ); |
|
10532 | } |
|
10533 | ||
10534 | responseContainer = overwritten = undefined; |
|
10535 | } ); |
|
10536 | ||
10537 | // Delegate to script |
|
10538 | return "script"; |
|
10539 | } |
|
10540 | } ); |
|
10541 | ||
10542 | ||
10543 |
@@ 9275-9351 (lines=77) @@ | ||
9272 | } ); |
|
9273 | ||
9274 | // Detect, normalize options and install callbacks for jsonp requests |
|
9275 | jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
|
9276 | ||
9277 | var callbackName, overwritten, responseContainer, |
|
9278 | jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? |
|
9279 | "url" : |
|
9280 | typeof s.data === "string" && |
|
9281 | ( s.contentType || "" ) |
|
9282 | .indexOf( "application/x-www-form-urlencoded" ) === 0 && |
|
9283 | rjsonp.test( s.data ) && "data" |
|
9284 | ); |
|
9285 | ||
9286 | // Handle iff the expected data type is "jsonp" or we have a parameter to set |
|
9287 | if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { |
|
9288 | ||
9289 | // Get callback name, remembering preexisting value associated with it |
|
9290 | callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? |
|
9291 | s.jsonpCallback() : |
|
9292 | s.jsonpCallback; |
|
9293 | ||
9294 | // Insert callback into url or form data |
|
9295 | if ( jsonProp ) { |
|
9296 | s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); |
|
9297 | } else if ( s.jsonp !== false ) { |
|
9298 | s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; |
|
9299 | } |
|
9300 | ||
9301 | // Use data converter to retrieve json after script execution |
|
9302 | s.converters[ "script json" ] = function() { |
|
9303 | if ( !responseContainer ) { |
|
9304 | jQuery.error( callbackName + " was not called" ); |
|
9305 | } |
|
9306 | return responseContainer[ 0 ]; |
|
9307 | }; |
|
9308 | ||
9309 | // Force json dataType |
|
9310 | s.dataTypes[ 0 ] = "json"; |
|
9311 | ||
9312 | // Install callback |
|
9313 | overwritten = window[ callbackName ]; |
|
9314 | window[ callbackName ] = function() { |
|
9315 | responseContainer = arguments; |
|
9316 | }; |
|
9317 | ||
9318 | // Clean-up function (fires after converters) |
|
9319 | jqXHR.always( function() { |
|
9320 | ||
9321 | // If previous value didn't exist - remove it |
|
9322 | if ( overwritten === undefined ) { |
|
9323 | jQuery( window ).removeProp( callbackName ); |
|
9324 | ||
9325 | // Otherwise restore preexisting value |
|
9326 | } else { |
|
9327 | window[ callbackName ] = overwritten; |
|
9328 | } |
|
9329 | ||
9330 | // Save back as free |
|
9331 | if ( s[ callbackName ] ) { |
|
9332 | ||
9333 | // Make sure that re-using the options doesn't screw things around |
|
9334 | s.jsonpCallback = originalSettings.jsonpCallback; |
|
9335 | ||
9336 | // Save the callback name for future use |
|
9337 | oldCallbacks.push( callbackName ); |
|
9338 | } |
|
9339 | ||
9340 | // Call if it was a function and we have a response |
|
9341 | if ( responseContainer && jQuery.isFunction( overwritten ) ) { |
|
9342 | overwritten( responseContainer[ 0 ] ); |
|
9343 | } |
|
9344 | ||
9345 | responseContainer = overwritten = undefined; |
|
9346 | } ); |
|
9347 | ||
9348 | // Delegate to script |
|
9349 | return "script"; |
|
9350 | } |
|
9351 | } ); |
|
9352 | ||
9353 | ||
9354 |
@@ 8719-8784 (lines=66) @@ | ||
8716 | }); |
|
8717 | ||
8718 | // Detect, normalize options and install callbacks for jsonp requests |
|
8719 | jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
|
8720 | ||
8721 | var callbackName, overwritten, responseContainer, |
|
8722 | jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? |
|
8723 | "url" : |
|
8724 | typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" |
|
8725 | ); |
|
8726 | ||
8727 | // Handle iff the expected data type is "jsonp" or we have a parameter to set |
|
8728 | if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { |
|
8729 | ||
8730 | // Get callback name, remembering preexisting value associated with it |
|
8731 | callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? |
|
8732 | s.jsonpCallback() : |
|
8733 | s.jsonpCallback; |
|
8734 | ||
8735 | // Insert callback into url or form data |
|
8736 | if ( jsonProp ) { |
|
8737 | s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); |
|
8738 | } else if ( s.jsonp !== false ) { |
|
8739 | s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; |
|
8740 | } |
|
8741 | ||
8742 | // Use data converter to retrieve json after script execution |
|
8743 | s.converters["script json"] = function() { |
|
8744 | if ( !responseContainer ) { |
|
8745 | jQuery.error( callbackName + " was not called" ); |
|
8746 | } |
|
8747 | return responseContainer[ 0 ]; |
|
8748 | }; |
|
8749 | ||
8750 | // force json dataType |
|
8751 | s.dataTypes[ 0 ] = "json"; |
|
8752 | ||
8753 | // Install callback |
|
8754 | overwritten = window[ callbackName ]; |
|
8755 | window[ callbackName ] = function() { |
|
8756 | responseContainer = arguments; |
|
8757 | }; |
|
8758 | ||
8759 | // Clean-up function (fires after converters) |
|
8760 | jqXHR.always(function() { |
|
8761 | // Restore preexisting value |
|
8762 | window[ callbackName ] = overwritten; |
|
8763 | ||
8764 | // Save back as free |
|
8765 | if ( s[ callbackName ] ) { |
|
8766 | // make sure that re-using the options doesn't screw things around |
|
8767 | s.jsonpCallback = originalSettings.jsonpCallback; |
|
8768 | ||
8769 | // save the callback name for future use |
|
8770 | oldCallbacks.push( callbackName ); |
|
8771 | } |
|
8772 | ||
8773 | // Call if it was a function and we have a response |
|
8774 | if ( responseContainer && jQuery.isFunction( overwritten ) ) { |
|
8775 | overwritten( responseContainer[ 0 ] ); |
|
8776 | } |
|
8777 | ||
8778 | responseContainer = overwritten = undefined; |
|
8779 | }); |
|
8780 | ||
8781 | // Delegate to script |
|
8782 | return "script"; |
|
8783 | } |
|
8784 | }); |
|
8785 | ||
8786 | ||
8787 |