6 ], function( jQuery, nonce, rquery ) {
9 rjsonp = /(=)\?(?=&|$)|\?\?/;
11 // Default jsonp settings
14 jsonpCallback: function() {
15 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
16 this[ callback ] = true;
21 // Detect, normalize options and install callbacks for jsonp requests
22 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
24 var callbackName, overwritten, responseContainer,
25 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
27 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
30 // Handle iff the expected data type is "jsonp" or we have a parameter to set
31 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
33 // Get callback name, remembering preexisting value associated with it
34 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
38 // Insert callback into url or form data
40 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
41 } else if ( s.jsonp !== false ) {
42 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
45 // Use data converter to retrieve json after script execution
46 s.converters["script json"] = function() {
47 if ( !responseContainer ) {
48 jQuery.error( callbackName + " was not called" );
50 return responseContainer[ 0 ];
53 // force json dataType
54 s.dataTypes[ 0 ] = "json";
57 overwritten = window[ callbackName ];
58 window[ callbackName ] = function() {
59 responseContainer = arguments;
62 // Clean-up function (fires after converters)
63 jqXHR.always(function() {
64 // Restore preexisting value
65 window[ callbackName ] = overwritten;
68 if ( s[ callbackName ] ) {
69 // make sure that re-using the options doesn't screw things around
70 s.jsonpCallback = originalSettings.jsonpCallback;
72 // save the callback name for future use
73 oldCallbacks.push( callbackName );
76 // Call if it was a function and we have a response
77 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
78 overwritten( responseContainer[ 0 ] );
81 responseContainer = overwritten = undefined;