使用jquery ajax刷新同一页面上的PHP数据 [英] use jquery ajax to refresh PHP data on same page

查看:52
本文介绍了使用jquery ajax刷新同一页面上的PHP数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有mysql连接的PHP页面,一个选择查询,然后我正在使用PHP建立一个表.如果我想使用jQuery AJAX在同一页面上的setInterval上刷新数据,我将如何去做? (顺便说一句,我可以在另一个PHP页面上执行此操作,但是如果PHP内容在同一页面上,则我从未执行过此操作)

I have a PHP page with a mysql connection, a select query and then i'm building a table using PHP. If i wanted to use jQuery AJAX to refresh the data on a setInterval, on the same page, how would i go about doing that? (by the way i can do it to another PHP page but i've never done it if the PHP stuff is on the same page)

推荐答案

如果您想继续进行ajax调用,我建议您进行长时间轮询,这基本上意味着您有一个脚本,该脚本每次给定时间都通过ajax请求内容,并且它将每次都验证内容是否被修改,否则将再次等待并再次拨打电话.

If you want to keep making ajax calls i suggest you do long polling, which basically means you have a script that is requesting content via ajax every given time, and it will verify every time if the content has been modified, if not it will wait again and make another call.

我将 jQuery期刊更新程序用于聊天框,效果很好.

I used jQuery Periodical updater for a chat box and it worked perfectly.

如果您想进一步了解jQuery和AJAX的工作原理,请查看此

If you wnat to learn more about how jQuery and AJAX work, check out this Nettus article

这篇关于使用jquery ajax刷新同一页面上的PHP数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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