Skip to content

Instantly share code, notes, and snippets.

@seyhunak
Created March 14, 2014 13:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seyhunak/9547928 to your computer and use it in GitHub Desktop.
Save seyhunak/9547928 to your computer and use it in GitHub Desktop.
Coffeescript - Ajax Request
$(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>');
@n350071
Copy link

n350071 commented Mar 27, 2018

It works! You made my day! Thanks you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment