Created
March 7, 2014 10:15
-
-
Save anthonybrown/9408974 to your computer and use it in GitHub Desktop.
Ajax basic jQuery template
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
$('.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