jquery.mockjax.js
function isMockDataEqual( mock, live ) {
		var identical = true;
		// Test for situations where the data is a querystring (not an object)
		if (typeof live === 'string') {
			// Querystring may be a regex
			return $.isFunction( mock.test ) ? mock.test(live) : mock == live;
		}
		$.each(mock, function(k) {
			if ( live[k] === undefined ) {
				identical = false;
				return identical;
			} else {
				if ( typeof live[k] === 'object' && live[k] !== null ) {
					if ( identical && $.isArray( live[k] ) ) {
						identical = $.isArray( mock[k] ) && live[k].length === mock[k].length;
					}
					identical = identical && isMockDataEqual(mock[k], live[k]);
				} else {
					if ( mock[k] && $.isFunction( mock[k].test ) ) {
						identical = identical && mock[k].test(live[k]);
					} else {
						identical = identical && ( mock[k] == live[k] );
					}
				}
			}
		});

		return identical;
	}
function isMockDataEqual( mock, live ) {
		var identical = true;
		// Test for situations where the data is a querystring (not an object)
		if (typeof live === 'string') {
			// Querystring may be a regex
			return $.isFunction( mock.test ) ? mock.test(live) : mock == live;
		}
		$.each(mock, function(k) {
			if ( live[k] === undefined ) {
				identical = false;
				return identical;
			} else {
				if ( typeof live[k] === 'object' && live[k] !== null ) {
					if ( identical && $.isArray( live[k] ) ) {
						identical = $.isArray( mock[k] ) && live[k].length === mock[k].length;
					}
					identical = identical && isMockDataEqual(mock[k], live[k]);
				} else {
					if ( mock[k] && $.isFunction( mock[k].test ) ) {
						identical = identical && mock[k].test(live[k]);
					} else {
						identical = identical && ( mock[k] == live[k] );
					}
				}
			}
		});

		return identical;
	}
function isMockDataEqual ( mock , live ) { var identical = true ; // Test for situations where the data is a querystring (not an object) if ( typeof live === 'string' ) { // Querystring may be a regex return $ . isFunction ( mock . test ) ? mock . test ( live ) : mock == live ; } $ . each ( mock , function ( k ) { if ( live [ k ] === undefined ) { identical = false ; return identical ; } else { if ( typeof live [ k ] === 'object' && live [ k ] !== null ) { if ( identical && $ . isArray ( live [ k ] ) ) { identical = $ . isArray ( mock [ k ] ) && live [ k ] . length === mock [ k ] . length ; } identical = identical && isMockDataEqual ( mock [ k ] , live [ k ] ) ; } else { if ( mock [ k ] && $ . isFunction ( mock [ k ] . test ) ) { identical = identical && mock [ k ] . test ( live [ k ] ) ; } else { identical = identical && ( mock [ k ] == live [ k ] ) ; } } } } ) ; return identical ; }
Check if the data field on the mock handler and the request match. This can be used to restrict a mock handler to being used only when a certain set of data is passed to it.
Check if the data field on the mock handler and the request match . This can be used to restrict a mock handler to being used only when a certain set of data is passed to it .