How can i stop ajax request (don't wait untill response come)?

后端 未结 5 926
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-10 18:46

If I use Ajax to send request and this request take long time ..... if I want to send anther request what should I do?

the current behaviour the second request

5条回答
  •  误落风尘
    2021-02-10 19:06

    I have been working on this many ways and I feel I found a working solution. I had a caching process that was causing a page to hang until done (average 5 seconds). Yes this is better suited as a CRON job, but I needed to create caching process for the user without knowing the environment they are using for my CMS. What I had done: Create the call within a variable and then remove it by a hard delete. By deleting this it seems to be removing the wait. This "hack" seemed to pull the wait from 5 second average to a 325ms wait.

    var ignore = $.ajax({
        url:something/here.php,
        type: "GET",
        url: url1,
        success: function(){}
    });
    delete ignore;
    

提交回复
热议问题