Skip to content

Instantly share code, notes, and snippets.

@shankardevy
Last active July 8, 2017 13:26
Show Gist options
  • Save shankardevy/79200f4f71529fa28ee1c9c28e2e1982 to your computer and use it in GitHub Desktop.
Save shankardevy/79200f4f71529fa28ee1c9c28e2e1982 to your computer and use it in GitHub Desktop.
function ajaxHandler(e) {
e.preventDefault()
var post_url = $(this).attr("action"); //get form action url
var form_data = $(this).serialize(); //Encode form elements for submission
$.post( post_url, form_data, function( response ) {
$.bootstrapGrowl(response.message, {
offset: {from: 'top', amount: 60},
type: 'success'
});
$(".cart-count").text(response.cart_count)
});
}
var ajaxCart = {
init: function() {
$(function(){
$(".cart-form").on('submit', ajaxHandler)
})
}
}
export default ajaxCart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment