In my application I have a shuffle button to start and stop the mockjax
response. as a first time, I am initiating the mockjax it works. later the user click on off
button to stop mockjax
service. ( I am showing server data )
for stop I use:
stopSimulation : function( ) {
if( !this.retriveSimulationStatus() ) {
console.log("i switched off!!");
$.mockjax.clear(); //removes the simulation;
}
}
But user clicks back to start
button, But mockjax
not intercepting again to provide the data.
so what is the correct way to stop and start the mockjax
service? any one help me?
Clearing the Mockjax handlers does NOT "stop" them, it erases them from Mockjax. There is no "start"/"stop" functionality. You will need to clear the handlers, then re-add the handlers when you want to start. Here's an example:
var handler = { url: '/foo', responseText: { foo: 'bar' } };
function start() {
$.mockjax(handler);
}
function stop() {
$.mockjax.clear();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.