I am using .ajax to get the price of a product. It returns fine. Outside of the .ajax function, when I go to alert it, it produces an undefined. Before the .ajax, I do a "var price;".
- var price;
- $.ajax({ url: 'process.php',
data: { productID2 : product},
type: 'post',
success: function(output) {
- if(output){
price=output;
}
}
});
- alert(price)
What would cause the price var to loose its value?