[jQuery] retrieve values from func that calls a $.post
Hi guys!
I'm having some problem, because I'm rearanging my programming
method.
I have the shoppingcart object, and it can fire many methods.
But for examples i have a method "shoppingcart.set(id,prop,value);"
that makes an ajax call via $.post and set for example the prop
"quantity" to 5 in the cart.
In the callback of the ajaxcall it sets shoppingcart.lastoperation=1;
(that means last operation OK)
then for example if I need to retrieve that value for a control, out
from the callback, because the $.post is asyncr, i get the default
value (shoppingcart.lastoperatio=0).
//CODE EXAMPLE
shoppingcart.lastoperation=0;
shoppingcart.set(5,quantity,12); //in the callback sets
shoppingcart.lastoperation=1;
alert(shoppingcart.lastoperation); //it returns 0
Can someone Help me?
PS: sorry for my bad english!