AJAX - 定时 mySQL 查询(请等待屏幕)
我需要创建一个 AJAX 页面,在页面加载时查询数据库,然后每 5-10 秒查询一次。与此同时,我将显示某种等待页面(可能带有动画 gif 来让我的客户开心:))
我正在与 paypals IPN 合作,所以它是在我等待交易清算时使用的。大多数时候它在用户返回之前清除,但有时不会。因此,如果有人有这样的代码或者可以向我指出这样的代码的方向,那就太好了。
I need to make an AJAX page which queries the database on page load and then every 5-10 seconds after that. In the meantime I will display some kind of waiting page (maybe with a animated gif to keep my customers entertained :) )
I am working with paypals IPN so its for while I am waiting for the transaction to clear.. most of the time it clears before the user returns, but sometimes it does not. So if anyone has such code or could point me in the direction of such code that would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://www.w3schools.com/js/js_timing.asp(允许您在 X 秒内做某事)
http://docs.jquery.com/Ajax/jQuery.get (是否AJAX 请求)
使用 setTimeout 和 jQuery get 轮询您的脚本。让脚本响应 IPN 请求的状态。使用 jQuery get 解析脚本的响应,并确定是否应该显示等待图像或告诉用户一切已成功。
希望这能为您指明正确的方向。
http://www.w3schools.com/js/js_timing.asp (Allows you to do something in X seconds)
http://docs.jquery.com/Ajax/jQuery.get (Does an AJAX request)
Use setTimeout and jQuery get to poll your script. Have the script respond with the status of the IPN request. Use jQuery get to parse the script's response and figure out if you should be showing a waiting image or telling the user everything that it was successful.
Hopefully that will point you in the right direction.
对于任何其他正在寻找“请稍候”脚本的人 - 这个脚本是一个很好的起点:
http://www.aleixcortadellas.com/main/2009/02/15/automatically-query-mysql-and-output-results-with-ajax /
我所要做的就是替换
为:
然后在 boo.php 中
我让它查询我的 IPN 状态列。
希望这对其他人有帮助。
For anyone else looking for a 'please wait' script - This one makes an excellent starting point:
http://www.aleixcortadellas.com/main/2009/02/15/automatically-query-mysql-and-output-results-with-ajax/
All I had to do was replace
With:
And then in boo.php
I made it query my IPN status column.
Hope this helps someone else.