This file contains hidden or 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
| function doTask(i){ | |
| // Create a new process. | |
| var defer = $.Deferred(); | |
| // Start main task in the process | |
| setTimeout(function(){ | |
| log("Step " + (i+1) + " finished."); | |
| // Terminate the processs upon successful finish. | |
| defer.resolve(i); |
This file contains hidden or 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
| function doTask1(add, multiply){ | |
| setTimeout(function(){ | |
| var rslt = Math.floor(Math.random() * 10); | |
| log("Task 1 returned " + rslt); | |
| if(rslt >= 5) | |
| add(rslt); | |
| else | |
| multiply(rslt); | |
| }, 500); | |
| } |
This file contains hidden or 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
| function doTask1(){ | |
| var rslt = Math.floor(Math.random() * 10); | |
| log("Task 1 returned " + rslt); | |
| return rslt; | |
| } | |
| function addTask(i){ | |
| var rslt = Math.floor(Math.random() * 10); | |
| log("addTask finished with " + rslt); | |
| return i + rslt; |
This file contains hidden or 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
| function doTask(i){ | |
| setTimeout(function(){ | |
| if(i < 5){ | |
| log("Step " + ++i + " finished."); | |
| doTask(i++); | |
| }else | |
| log("All steps done."); | |
| }, Math.random()*1000); | |
| } |
This file contains hidden or 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
| function doTask(i, next){ | |
| setTimeout(function(){ | |
| log("Step " + ++i + " finished."); | |
| next(); | |
| }, Math.random()*1000); | |
| } | |
| $(function(){ | |
| doTask(0, function(){ | |
| doTask(1, function(){ |
This file contains hidden or 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
| function doTask(i){ | |
| setTimeout(function(){ | |
| log("Step " + ++i + " finished."); | |
| }, Math.random()*1000); | |
| } |
This file contains hidden or 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
| <div id="log"></id> | |
| <script type="text/javascript"> | |
| var log = function(content){ | |
| $('<p/>').html(content).appendTo('#log'); | |
| } | |
| function doTask(i){ | |
| log("Step " + ++i + " finished."); | |
| } |
This file contains hidden or 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
| $.ajax("http://somewhere.net") | |
| .success(function(){ alert("success"); }) | |
| .error(function(){ alert("error"); }); |
This file contains hidden or 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
| $.ajax({ | |
| url: "http://somewhere.net", | |
| success: function(){ alert("success"); }, | |
| error: function(){ alert("error"); } | |
| }); |
This file contains hidden or 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
| <script type="text/javascript"> | |
| function reorder(table, row) { | |
| if(!table) | |
| table = $("#QuizTable")[0]; | |
| var rows = table.tBodies[0].rows; | |
| var step = 1; | |
| for (var i = 1; i < rows.length; i++) { | |
| $(".orderbox", rows[i]).val(step++); | |
| } |