PHP和放大器;而不必等待回应jQuery的Ajax调用 [英] PHP & jQuery ajax call without waiting for response

查看:211
本文介绍了PHP和放大器;而不必等待回应jQuery的Ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我挣扎的东西。

我有一个PHP页面,做一个Ajax调用使用jQuery $。阿贾克斯另一页。这将请求发送异步的处理页面,然后返回响应。

I have an PHP page that does an ajax call to another page using jQuery $.ajax. It sends the request async to the processing page which then returns a response.

这工作得很好,但现在我们正在做一些改变到后台,并运行现在正在长了不少像超过5分钟处理(SQL存储过程)。等待的是好的,因为我们正在密切打交道200MM记录SQL。

This works fine now but we are making some changes to the backend and the processing (SQL stored procedure) that runs is now taking a lot longer like well over 5 minutes. The wait is is fine because we are dealing with close to 200MM records in SQL.

的事情是我需要能够将请求发送到处理页面,而不必等待一个响应。处理页面打完存储过程中的PHP这样的:

The thing is I need to be able to send the request to the processing page and not have to wait for a response. The processing page fires off the stored procedure in PHP like this:

            $query = $dbh2->prepare('exec sp_name :countID');
            $query->bindParam('countID', $countID);
            $query->execute();

现在再次该存储过程需要一段时间来运行,我们不需要的,结果是psented返回给用户$ P $。还有,虽然需要在存储过程之后运行,但再没有什么需要被发送回浏览器的一些额外的PHP code。

Now again that stored procedure takes awhile to run and we do not need the results of that to be presented back to the user. There is though some additional PHP code that needs to run after the stored procedure but again nothing needs to be send back to the browser.

我试图想出一个办法,我可以打个电话给处理页面,它运行存储过程和其他code,但在用户的浏览器不需要等待响应。现在,如果尝试单击关闭页面太快就基本锁定了浏览器一段时间,没有完成的处理。

I am trying to figure out a way that I can make a call to the processing page and it runs the stored procedure and the other code but the user's browser does not need to wait for the response. Right now if the try to click off the page too soon it basically locks up the browser for awhile and does not finish the processing.

任何洞察到这将是巨大的。

Any insight into this would be great.

在此先感谢您的帮助。

推荐答案

Sequenzia,如果我理解正确的话,那么我以前来过这里,并通过这样的困境找到了一条了大量的研究后。

Sequenzia, if I understand correctly, then I've been here and found a way through this quagmire after a lot of research.

我在几个月前提供了一个答案,一个类似的问题。不幸的是,OP也没有任何人曾经接受/评论/ upvoted / downvoted - 缥缈

I provided an answer to a similar question a few months ago. Unfortunately, the OP nor anyone else has ever accepted/commented/upvoted/downvoted - nada.

  • <一个href="http://stackoverflow.com/questions/13617185/run-a-batch-file-from-my-website/13618558#13618558">Run从我的网站
  • 一个批处理文件
  • Run a batch file from my website

和这里有一些有用的参考资料:

And here are some useful references :

运行的后台脚本(UNIX命令)

  • Ref: http://nsaunders.wordpress.com/2007/01/12/running-a-background-process-in-php/
  • Ref: http://www.mathinfo.u-picardie.fr/asch/f/MeCS/courseware/users/help/general/unix/redirection.html

如何撰写PHP $ shortopts和$ longopts

这是方式传递给PHP脚本跨preT参数,在命令行中运行,或从另一个PHP脚本与外壳的exec()

这篇关于PHP和放大器;而不必等待回应jQuery的Ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆