Created
June 18, 2013 17:43
-
-
Save jswhisperer/5807612 to your computer and use it in GitHub Desktop.
Ajax in CoffeeScript
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
| $(document).ready -> | |
| # Basic Examples | |
| $.get '/', (data) -> | |
| $('body').append "Successfully got the page." | |
| $.post '/', | |
| userName: 'John Doe' | |
| favoriteFlavor: 'Mint' | |
| (data) -> $('body').append "Successfully posted to the page." | |
| # Advanced Settings | |
| $.ajax '/', | |
| type: 'GET' | |
| dataType: 'html' | |
| error: (jqXHR, textStatus, errorThrown) -> | |
| $('body').append "AJAX Error: #{textStatus}" | |
| success: (data, textStatus, jqXHR) -> | |
| $('body').append "Successful AJAX call: #{data}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment