Skip to content

Instantly share code, notes, and snippets.

@pitkane
Created February 13, 2017 12:33
Show Gist options
  • Save pitkane/108d265a54917e33a0e74ad546f14ed1 to your computer and use it in GitHub Desktop.
Save pitkane/108d265a54917e33a0e74ad546f14ed1 to your computer and use it in GitHub Desktop.
<!-- basket ajax -->
<script type="text/javascript">
/*
jQuery.ready(function($) {
jQuery("#basketForm_standalone").submit(function(e) {
var cart = jQuery('.Header .BasketBox');
/* var cart2 = jQuery('.NavBarRoof .BasketBox');
cart = cart2.height() ? cart2 : cart1; */
var imgtodrag = jQuery('#ProductSlideshow img');
if (imgtodrag) {
var imgclone = imgtodrag.clone()
.offset({
top: imgtodrag.offset().top,
left: imgtodrag.offset().left
})
.css({
'opacity': '0.5',
'position': 'absolute',
'height': imgtodrag.height(),
'width': imgtodrag.width(),
'z-index': '9999'
})
.appendTo(jQuery('body'))
.animate({
'top': cart.offset().top + 10,
'left': cart.offset().left + 10,
'width': 75,
'height': 75
}, 1500, 'easeInOutExpo');
}
// jQuery('body').busy("show");
var postData = jQuery(this).serializeArray();
var formURL = jQuery(this).attr("action");
jQuery.ajax({
url: formURL,
type: "POST",
data: postData,
success: function(data, textStatus, jqXHR) {
imgclone.animate({
'width': 0,
'height': 0
}, function() {
jQuery(this).detach()
});
// jQuery('body').busy("hide");
// basket1 = jQuery(data).find('.NavBarRoof .BasketBox');
basket2 = jQuery(data).find('.Header .BasketBox');
// jQuery('.NavBarRoof .BasketBox').replaceWith(basket1);
jQuery('.Header .BasketBox').replaceWith(basket2);
// console.error(basket1);
},
error: function(jqXHR, textStatus, errorThrown) {
// jQuery('body').busy("hide");
alert('something went wrong');
}
});
// e.preventDefault(); //STOP default action
// });
// });*/
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment