I have two functions
First function:
sendRequest: function () {
jQuery.ajax({
type: 'POST',
url: xtremeSearchUrl,
dataType: 'json',
async: true,
data: JSON.stringify(data),
success: function (data) {
data = this.searchBP();
if (data == false) {
}else{
}
},error{
}});
}
Second function:
searchBP: function () {
var $url = "/bP";
var $data = {url: window.location.pathname};
jQuery.ajax({
type: 'POST',
url: $url,
data: $data,
success: function (result) {
console.log(result);
return true;
},
error: function (xhr, status, error) {
console.log(xhr);
console.log(status);
console.log(error);
return false;
}
});
}
I understand that ajax runs asynchronously and when you put the async in false pause the whole page, what I need to do is that when you call the function searchBP () nothing else will be executed until you return the true or false and handle according to that answer another block of code in sendRequest