It took me two days to find a way.
By the way, the Django paging stuff is also familiar.
If we don't use the latest deferred, we used to be very difficult to read and long.
The following is not an optimized code encapsulation.
This parameter renders the global call with non-Var.
And added Ajax pre-processing and end processing. Let the page present the upgrade information for the user.
var_self = This; Promisea=$.ajax ({URL:' {% url ' cp-dir '%} ', type:' Post ', data:{tgt:tgt,}, DataType: ' JSON ', Beforesend:function() {$ (_self). attr (' Disabled ', ' true '); $ (_self). Append ("<i class= ' uk-icon-cog uk-icon-spin ' ></i>"); }, Error:function() {alert (' Error loading JSON document '); }, Success:function(JSON) {uikit.notify ("Cp-dir", {status: ' Info ', timeout:1000}); varJSON =eval (JSON); $.each (JSON,function(Index, item) {uikit.notify (Json[index], {status:' Info ', timeout:1000}); }); } }); Promiseb= Promisea.then (function(){ return$.ajax ({URL:' {% url ' auto_deploy:cmd-run '%} ', type:' Post ', data:{tgt:tgt,}, DataType:' JSON ', Error:function() {alert (' Error loading JSON document '); }, Success:function(JSON) {uikit.notify ("Cmd-run", {status: ' Info ', timeout:1000}); varJSON =eval (JSON); $.each (JSON,function(Index, item) {uikit.notify (Json[index], {status:' Info ', timeout:1000}); }); }, Complete:function() {$ (_self). Children (I). Remove (); $ (_self). Append ("<i class= ' Uk-icon-check ' ></i>") } }); });
Asynchronously invokes the backend API sequentially with the deferred of jquery