Skip to content

Instantly share code, notes, and snippets.

@amorphid
Created August 29, 2013 02:36
Show Gist options
  • Select an option

  • Save amorphid/6373683 to your computer and use it in GitHub Desktop.

Select an option

Save amorphid/6373683 to your computer and use it in GitHub Desktop.
# from controller
respond_to do |format|
format.html { redirect_to :back }
format.json { render json: @voteable.score } # score is an integer
end
# from application.js
$(document).ready(function() {
$(".posts li").each(function(){
$("a.icon-chevron-up").click(function(event){
event.preventDefault();
$.ajax({
dataType: "json",
type: "POST",
url: $(this).attr("href"),
success: function(data) {
console.log(data);
}
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment