aws elastic web python stops ajax requests if new request is made

The solution for “aws elastic web python stops ajax requests if new request is made” can be found here. The following code will assist you in solving the problem.

async function runCodes(){

//this code its gonna run async
ajaxCall().then((response)=>{
if(response){
//true
} else {
//false
}
});

//some other codes

}

function ajaxCall(){
return new Promise((resolve) => {
$.ajax({
url: ‘/controller.php’,
type: ‘GET’,
dataType: “json”,
data: {
action: “loadPageContent”
},
success: function(retour) {
localStorage.removeItem(‘myhtml’);
if(retour.status && retour.htmlDatas){
storedDatas[“posts”] = retour.htmlDatas;
storedDatas[“date_scrapping”] = retour.date_scrapping;
localStorage.setItem(“myhtml”, JSON.stringify(storedDatas) ); // ¨Pour si relance

$(‘#container’).html(retour.htmlDatas);
resolve(true);

}
else {
alert(‘error’);
resolve(false);
}

},
error: function(retour) {
alert(‘error’);
resolve(false);
},
});
});
}

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in