I have this code with an ajax call.
var value = 0;
$.ajax({
url: 'http://localhost:3000',
dataType: "json",
type: 'POST',
data: formdata,
success: function(data, textStatus, jqXHR) {
value = data.data;
console.log("Inside: " + value);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log("Error received");
}
});
console.log("Outside: " + value);
Executing, gives me
Outside: 0
Inside: 100
Is there anyway to make it run sequentially?
console.log("Outside: "+value)code inside thesuccesscallback, after the "Inside" thing?