function addItemToCart (id_1, id_2, id_3, id_etc) {
jQuery.ajax({
});
}
function clearCart()
{
jQuery.ajax({
});
}
function buyButton()
{
clearCart();
setTimeout(function()
{
redirect to cart;
addItemToCart(283746 , 1, 1, "Months", "1294");
}, 500);
}
I'm trying to make it so that instead of using a setTimeout it waits until the clearCart() has finished loading through ajax and then it runs the functions inside the setTimeout and I can't seem to figure this out.. I tried doing a callback but I'd say that it isn't correct..
function FirstFunction(callBack)
{
clearCart();
if (callback)
{
callback();
}
}
function SecondFunction()
{
buyButton();
}
FirstFunction(SecondFunction);