So this is working for me, but ideally i would like to not iterate through the array recusrively like this, and just pass in the array, but I cant get that to work. Can anybody improve on the below for me?
Thanks!
function ajax_AddToCart(itemsToAdd, itemIndex){
jQuery.ajax({
type: ‘POST’,
url: ‘/cart/add.js’,
data: itemsToAdd[itemIndex],
dataType: ‘json’,
success: function() {
itemIndex += 1;
if(itemIndex < numItems){
ajax_AddToCart(itemsToAdd, itemIndex)
} else{
location.href = “/cart”
}
}
});
}