PDA

View Full Version : It's a Race!



bfly03
04-16-2010, 02:37 PM
I am pretty sure I am creating a race but I do not know how to go about fixing it... any ideas?

cheers,



$('.add-items').live('click', function(evt) {
if (evt.button != 0) return; // ignore right-click
evt.preventDefault();

var items = $(this).attr('href').substr(1).split(',');
// now items is ['G400180', 'G400181']

// Disable the link to prevent repeated orders
$(this).attr('disabled','disabled');

// Execute the orders using ajax
var remaining_requests_cnt = items.length;
for (var i = 0; i < items.length; i++) {
$.ajax({
url: '/cgi/cart.cgi?'+items[i],
success: function() {
if (--remaining_requests_cnt == 0) {
top.location.href="http://www.feelgoodlightups.com/cgi/cart.cgi?viewcart";
}
},
error: function() {
alert('Error occurred. Check the content of your cart.');
location.reload();
},
})
}
});

djr33
04-16-2010, 07:34 PM
What is a race? What is the goal of this project?