Im really breaking by head on this one. Ive read a lot about callbacks and know ajax is asynchronous but I cant for the life of me find how to get a value back that I can use later on in a if statement.
$.ajax({
url: 'http://'+document.domain+'/klanten/updateaddress.php',
type: 'post',
data: poststring,
success: function(result) {
console.log("result = "+result);
callbacks.add(result);
}
});
//this doesnt work because result is generated asynchonous.
if(result == success){
//do something
}
the console.log perfectly shows success or an error I generated in updateaddress.php and I really need to use the if statement to execute some code after it has gotten success or not. Can anyone explain to me how the callback system works in this case?
Thanks!