I am having an issue getting an Ajax Response to be used within an Object.
function cart(){
this.items = [];
this.addItem = function(item){
//sorts and adds items to this.items
}
this.retrieveCart = function(){
var itemArray = JSON.parse($.cookie('cartItems'));
var itemNumbers = [];
var outData = [];
for(var i in itemArray){
itemNumbers.push(i);
}
$.post('beta-category-ajax.html', {'get' : itemNumbers.join(",")},
function(data){
for(var i in data){
var currentItemNumber = data[i].I;
var quantity = itemArray[currentItemNumber];
data[i].Quantity = quantity;
outData.push(data[i]);
}
});
this.addItem(outData);
}
I want to be able to run the this.addItem(Array)
while still using Ajax asynchronously
I saw this thread jQuery AJAX Handling Problem but I am not if this applies to me.
Thank you all for the help ahead of time :)