Created
November 8, 2012 02:07
-
-
Save ElemarJR/4036107 to your computer and use it in GitHub Desktop.
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Deferred Objects</title> | |
| </head> | |
| <body> | |
| <button id="resolveButton">resolve</button> | |
| <button id="rejectButton">reject</button> | |
| <button id="getStateButton">get state</button> | |
| <div id="output"/> | |
| <script src="http://code.jquery.com/jquery-latest.js"></script> | |
| <script> | |
| var def = $.Deferred() | |
| .done(function() {$("#output").text("success!");}) | |
| .fail(function() {$("#output").text("fail!");}) | |
| .always(function() {alert('def state changed to ' + def.state());}) | |
| $("#resolveButton").click(function() { | |
| def.resolve(); | |
| }); | |
| $("#rejectButton").click(function() { | |
| def.reject(); | |
| }); | |
| $("#getStateButton").click(function() { | |
| alert('def object state = ' + def.state()); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment