i have js function
function addAllToCart(){
var have_result = false;
jQuery("input#qty").each(function(indx, e){
if (e.value != ''){
//alert(indx);
jQuery.get("/checkout/cart/add/", { product: e.name, qty: e.value }, {async: false},
function(data){});
have_result = true;
}
});
if (have_result)
document.location.href = "/checkout/cart/";
return false;
}
it find on page all inputs with id qty, get it name and value and make ajax request to add to cart. there are many these inputs on on page, so i need to add all of them and then rediret to “/checkout/cart/”; but only first value adds to cart and then works redirect. how can i do redirect only after making all ajax requests??
here is the signature of jQuery.get
you don’t call the method correctly.
Also, you should use
postinstead ofgetto add your items into session or db.Getdoes work in practice, you can get item information from query strings. but It’s just wrong doing it this way. you should usepost