Skip to content

Instantly share code, notes, and snippets.

@anthonybrown
Created March 7, 2014 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonybrown/9408974 to your computer and use it in GitHub Desktop.
Save anthonybrown/9408974 to your computer and use it in GitHub Desktop.
Ajax basic jQuery template
$('.show-comments').on('click', function(e) {
e.preventDefault();
$.ajax({
url: 'http://jsbin.com/Amen/2/js'
, type: 'get'
, dataType: 'json'
, success: function (data) {
$('.comment-count').text( formatCommentCount(data.length) );
$.each(data, function() {
$('#comment-list').append( commentTemplate(this) );
});
}
, error: function( xhr, textStatus ) {
var errorText = 'An error has occured: ';
$('#notification').append( errorText + textStatus );
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment