标签:http io os ar java for sp 数据 div
// Bind script tag hack transport
jQuery.ajaxTransport( "script", function(s) {
	// This transport only deals with cross domain requests
	  if ( s.crossDomain ) {
		    var script,
			    head = document.head || jQuery("head")[0] || document.documentElement;
return {
send: function( _, callback ) {
script = document.createElement("script");
script.async = true;
				        if ( s.scriptCharset ) {
					          script.charset = s.scriptCharset;
				        }
script.src = s.url;
				        // Attach handlers for all browsers
				        script.onload = script.onreadystatechange = function( _, isAbort ) {
if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
						            // Handle memory leak in IE
						            script.onload = script.onreadystatechange = null;
						            // Remove the script
						            if ( script.parentNode ) {
							              script.parentNode.removeChild( script );
						            }
						            // Dereference the script
						            script = null;
						            // Callback if not abort
						            if ( !isAbort ) {
							              callback( 200, "success" );
						            }
					          }
				        };  
				        // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
				        // Use native DOM manipulation to avoid our domManip AJAX trickery
				        head.insertBefore( script, head.firstChild );
			      },
			      abort: function() {
				        if ( script ) {
					          script.onload( undefined, true );
				        }
			      }
		    };
	  }
});
var oldCallbacks = [],
	rjsonp = /(=)\?(?=&|$)|\?\?/;
// Default jsonp settings
jQuery.ajaxSetup({
	  jsonp: "callback",
	  jsonpCallback: function() {
		    var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
		    this[ callback ] = true;
		    return callback;
	  }
});
jsonp的实现与原理:
标签:http io os ar java for sp 数据 div
原文地址:http://www.cnblogs.com/cdwp8/p/4052581.html