Created
March 14, 2014 13:46
-
-
Save seyhunak/9547928 to your computer and use it in GitHub Desktop.
Coffeescript - Ajax Request
This file contains 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 -> | |
$.ajax '/items/get_list', | |
type: 'GET' | |
dataType: 'json' | |
beforeSend: -> | |
$('#loading').html "<img src='/assets/loading.gif' /> Now loading..." | |
error: (jqXHR, textStatus, errorThrown) -> | |
$('#items').html "Error: #{textStatus}" | |
success: (data, textStatus, jqXHR) -> | |
$('#loading').hide(); | |
$.each data, (index, item) -> | |
$('#items').append('<div class="items">' + '<p>' + item.title + '</p>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It works! You made my day! Thanks you.