Why does this code not work?
It should wait for step 1 to load before loading step 2.Currently, step 2 fires first. I am using mockjax to simulate the Ajax calls.
$.mockjax({
url: "/step1",
responseTime: [3000, 4000],
responseText: {
status: "success",
text: "Loading Step 1"
}
});
$.mockjax({
url: "/step2",
responseTime: [100, 200],
responseText: {
status: "success",
text: "Loading step 2"
}
});
$.getJSON("/step1").then( function(response) {
return $("#message").html( "message: " + response.text );
})
.then(
$.getJSON("/step2", function(response) {
$("#message").html( "message: " + response.text );
})
)