Skip to content

Instantly share code, notes, and snippets.

@trestles
Created May 14, 2014 17:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trestles/284ced332673d0538417 to your computer and use it in GitHub Desktop.
Save trestles/284ced332673d0538417 to your computer and use it in GitHub Desktop.
// assign to body tag such that if it's html written to DOM after page has been loaded, if not
// $('.buy-btn').on('click', function(){
$('body').on('click', '.buy-btn', function(){
if($("#package-1").is(':checked')){
// get pacakge-sub-values and build data_val
data_val={{package_1:true, ....}}
}else if($("#package-2").is(':checked')) {
// get pacakge-sub-values
data_val={{package_2:true, ....}}
}
$.ajax({
url: "/arc/v1/api/order/", j
type: 'POST',
data: data_val,
dataType: 'json'
}).done(function(r) {
// r is what your api has returned
// wipe out the form via something like:
$('#order-form').hide('slow');
$('#order-container').html('thx for order. An email has been sent')
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment