jquery.mockjax.js
function processJsonpRequest( requestSettings, mockHandler, origSettings ) {
		// Synthesize the mock request for adding a script tag
		var callbackContext = origSettings && origSettings.context || requestSettings,
			newMock = null;


		// If the response handler on the moock is a function, call it
		if ( mockHandler.response && $.isFunction(mockHandler.response) ) {
			mockHandler.response(origSettings);
		} else {

			// Evaluate the responseText javascript in a global context
			if( typeof mockHandler.responseText === 'object' ) {
				$.globalEval( '(' + JSON.stringify( mockHandler.responseText ) + ')');
			} else {
				$.globalEval( '(' + mockHandler.responseText + ')');
			}
		}

		// Successful response
		setTimeout(function() {
			jsonpSuccess( requestSettings, callbackContext, mockHandler );
			jsonpComplete( requestSettings, callbackContext, mockHandler );
		}, parseResponseTimeOpt(mockHandler.responseTime) || 0);

		// If we are running under jQuery 1.5+, return a deferred object
		if($.Deferred){
			newMock = new $.Deferred();
			if(typeof mockHandler.responseText == "object"){
				newMock.resolveWith( callbackContext, [mockHandler.responseText] );
			}
			else{
				newMock.resolveWith( callbackContext, [$.parseJSON( mockHandler.responseText )] );
			}
		}
		return newMock;
	}
function processJsonpRequest( requestSettings, mockHandler, origSettings ) {
		// Synthesize the mock request for adding a script tag
		var callbackContext = origSettings && origSettings.context || requestSettings,
			newMock = null;


		// If the response handler on the moock is a function, call it
		if ( mockHandler.response && $.isFunction(mockHandler.response) ) {
			mockHandler.response(origSettings);
		} else {

			// Evaluate the responseText javascript in a global context
			if( typeof mockHandler.responseText === 'object' ) {
				$.globalEval( '(' + JSON.stringify( mockHandler.responseText ) + ')');
			} else {
				$.globalEval( '(' + mockHandler.responseText + ')');
			}
		}

		// Successful response
		setTimeout(function() {
			jsonpSuccess( requestSettings, callbackContext, mockHandler );
			jsonpComplete( requestSettings, callbackContext, mockHandler );
		}, parseResponseTimeOpt(mockHandler.responseTime) || 0);

		// If we are running under jQuery 1.5+, return a deferred object
		if($.Deferred){
			newMock = new $.Deferred();
			if(typeof mockHandler.responseText == "object"){
				newMock.resolveWith( callbackContext, [mockHandler.responseText] );
			}
			else{
				newMock.resolveWith( callbackContext, [$.parseJSON( mockHandler.responseText )] );
			}
		}
		return newMock;
	}
function processJsonpRequest ( requestSettings , mockHandler , origSettings ) { // Synthesize the mock request for adding a script tag var callbackContext = origSettings && origSettings . context || requestSettings , newMock = null ; // If the response handler on the moock is a function, call it if ( mockHandler . response && $ . isFunction ( mockHandler . response ) ) { mockHandler . response ( origSettings ) ; } else { // Evaluate the responseText javascript in a global context if ( typeof mockHandler . responseText === 'object' ) { $ . globalEval ( '(' + JSON . stringify ( mockHandler . responseText ) + ')' ) ; } else { $ . globalEval ( '(' + mockHandler . responseText + ')' ) ; } } // Successful response setTimeout ( function ( ) { jsonpSuccess ( requestSettings , callbackContext , mockHandler ) ; jsonpComplete ( requestSettings , callbackContext , mockHandler ) ; } , parseResponseTimeOpt ( mockHandler . responseTime ) || 0 ) ; // If we are running under jQuery 1.5+, return a deferred object if ( $ . Deferred ) { newMock = new $ . Deferred ( ) ; if ( typeof mockHandler . responseText == "object" ) { newMock . resolveWith ( callbackContext , [ mockHandler . responseText ] ) ; } else { newMock . resolveWith ( callbackContext , [ $ . parseJSON ( mockHandler . responseText ) ] ) ; } } return newMock ; }
Process a JSONP request by evaluating the mocked response text
Process a JSONP request by evaluating the mocked response text