Skip to content

Instantly share code, notes, and snippets.

@jswhisperer
Created June 18, 2013 17:43
Show Gist options
  • Select an option

  • Save jswhisperer/5807612 to your computer and use it in GitHub Desktop.

Select an option

Save jswhisperer/5807612 to your computer and use it in GitHub Desktop.
Ajax in CoffeeScript
$(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