I'm calling post ajax method and I want the result in sequence and I want program to wait for the response. Basically, I want callback to come in sequence.
But after await line in TreeReportSentimentLoad function, program doesn't go on next line. It just basically stops there. I want to make my code synchronous. I have multiple calls one after another, and i want their responses to be in same order.
Also, If i just do async:false
in ajax call, page freezes, so this is why I'm trying this way but not working.
return new Promise(resolve => {
$.ajax({
type: "POST",
url: url,
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
})
})
}
async function TreeReportSentimentLoad() {
url = "some url"
var promised = await ajaxCallForSentiment(url);
console.log('after promise')
promised.then(function (data) {
console.log(data);
})
}
TreeReportSentimentLoad()