I have a web app which must call the server multiple times. So far, I had a long nested callback chain; but I would like to use jQuery's when
,then
etc. functionality. However, I can't seem to get stuff running again after using a then
.
$
.when ($.get('pages/run-tool.html'))
.then (function (args)
{
// This works fine
alert(args);
$('#content').replaceWith (args);
$('#progress-bar').progressbar ({value: 0});
})
.then ($.get('pages/test.html'))
.done (function(args)
{
// This prints the same as the last call
alert (args);
});
What am I doing wrong? I guess its some scoping issue, as I can see the second get
call being executed. Using two different args
variables does not help as the argument passed to the done function is still the first get
request.
My way is to apply callback function:
where A, B can be written as