Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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

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);
            },  
        });
      });
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #aws #elastic #web #python #stops #ajax #requests #request
ADD COMMENT
Topic
Name
4+7 =