jquery.mockjax.js
function processJsonpMock( requestSettings, mockHandler, origSettings ) {
		// Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here
		// because there isn't an easy hook for the cross domain script tag of jsonp

		processJsonpUrl( requestSettings );

		requestSettings.dataType = "json";
		if(requestSettings.data && CALLBACK_REGEX.test(requestSettings.data) || CALLBACK_REGEX.test(requestSettings.url)) {
			createJsonpCallback(requestSettings, mockHandler, origSettings);

			// We need to make sure
			// that a JSONP style response is executed properly

			var rurl = /^(\w+:)?\/\/([^\/?#]+)/,
				parts = rurl.exec( requestSettings.url ),
				remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);

			requestSettings.dataType = "script";
			if(requestSettings.type.toUpperCase() === "GET" && remote ) {
				var newMockReturn = processJsonpRequest( requestSettings, mockHandler, origSettings );

				// Check if we are supposed to return a Deferred back to the mock call, or just
				// signal success
				if(newMockReturn) {
					return newMockReturn;
				} else {
					return true;
				}
			}
		}
		return null;
	}
function processJsonpMock( requestSettings, mockHandler, origSettings ) {
		// Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here
		// because there isn't an easy hook for the cross domain script tag of jsonp

		processJsonpUrl( requestSettings );

		requestSettings.dataType = "json";
		if(requestSettings.data && CALLBACK_REGEX.test(requestSettings.data) || CALLBACK_REGEX.test(requestSettings.url)) {
			createJsonpCallback(requestSettings, mockHandler, origSettings);

			// We need to make sure
			// that a JSONP style response is executed properly

			var rurl = /^(\w+:)?\/\/([^\/?#]+)/,
				parts = rurl.exec( requestSettings.url ),
				remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);

			requestSettings.dataType = "script";
			if(requestSettings.type.toUpperCase() === "GET" && remote ) {
				var newMockReturn = processJsonpRequest( requestSettings, mockHandler, origSettings );

				// Check if we are supposed to return a Deferred back to the mock call, or just
				// signal success
				if(newMockReturn) {
					return newMockReturn;
				} else {
					return true;
				}
			}
		}
		return null;
	}
function processJsonpMock ( requestSettings , mockHandler , origSettings ) { // Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here // because there isn't an easy hook for the cross domain script tag of jsonp processJsonpUrl ( requestSettings ) ; requestSettings . dataType = "json" ; if ( requestSettings . data && CALLBACK_REGEX . test ( requestSettings . data ) || CALLBACK_REGEX . test ( requestSettings . url ) ) { createJsonpCallback ( requestSettings , mockHandler , origSettings ) ; // We need to make sure // that a JSONP style response is executed properly var rurl = / ^(\w+:)?\/\/([^\/?#]+) / , parts = rurl . exec ( requestSettings . url ) , remote = parts && ( parts [ 1 ] && parts [ 1 ] !== location . protocol || parts [ 2 ] !== location . host ) ; requestSettings . dataType = "script" ; if ( requestSettings . type . toUpperCase ( ) === "GET" && remote ) { var newMockReturn = processJsonpRequest ( requestSettings , mockHandler , origSettings ) ; // Check if we are supposed to return a Deferred back to the mock call, or just // signal success if ( newMockReturn ) { return newMockReturn ; } else { return true ; } } } return null ; }
Process a JSONP mock request.
Process a JSONP mock request .