weixin_33704234 2016-03-16 15:29 采纳率: 0%
浏览 43

jQuery AJAX中断“错误”

I have a .php script that takes very long to complete (anywhere from 30 to 160 seconds).

From a webpage I am able to run this script using the JQuery $.ajax() function. However, if I try to leave the page while the ajax request is in progress the function throws an error 'error', which I alert().

I was wondering however if the .php script continues? Because for my case it doesn't really matter if the webpage doesn't receive the response, as long as the .php script doesnt stop halfway trough.

So: if an $.ajax() is interrupted, does that .php script finish non-the-less?

  • 写回答

1条回答 默认 最新

  • weixin_33725515 2016-03-16 15:32
    关注

    It is possible to let the script run after closing the connection:

    http://php.net/manual/en/function.ignore-user-abort.php

    You might want to look into job queues if you have long running scripts which do background tasks.

    评论

报告相同问题?