Last active
December 21, 2015 01:59
-
-
Save wtarr/6231620 to your computer and use it in GitHub Desktop.
Mockjax test: All calls to the server will be intercepted and replaced with the mockjax response text. Output will be MOCKJAX!!!! x 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready( function() { | |
$.mockjax({ | |
// This should trigger a success and use my data | |
// as oppose to the data received from server | |
url: "http://localhost:8000/", | |
responseTime: 10, | |
dataType: 'text/json', | |
responseText: { "name" : "MOCKJAX!!!!" } | |
}); | |
$.getJSON('http://localhost:8000/').success(function (data) { | |
// Running local test server is set to respond with { "name" : "PYTHONSERVER" } | |
doSomethingWithData(data) | |
}); | |
$.getJSON('http://localhost:8000/').success(function (data) { | |
// Running local test server is set to respond with { "name" : "PYTHONSERVER" } | |
doSomethingWithData(data) | |
}); | |
$.getJSON('http://localhost:8000/').success(function (data) { | |
// Running local test server is set to respond with { "name" : "PYTHONSERVER" } | |
doSomethingWithData(data) | |
}); | |
function doSomethingWithData(data) | |
{ | |
console.log(data['name']); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment