刷新网页在PHP的一部分 [英] refresh a part of webpage in php

查看:160
本文介绍了刷新网页在PHP的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜的朋友                我开发一个网页,我需要刷新网页,不使用Ajax的整体之一的PHP的一部分。请帮我做这件事,在此先感谢

Hi friends i develop a page in that i need to refresh a part of a webpage,not a whole one in php using Ajax. Please help me to do this , thanks in advance

推荐答案

PHP不能做到这一点,只有一个客户端的语言,像JavaScript可以。话虽这么说,在 jQuery库将使你与它的 AJAX功能

PHP cannot do this, only a client-side language like JavaScript can. That being said, the jQuery library would allow you to do this really easily with its AJAX functionality.

的index.php

<div id="scores"><!-- score data here --></div>

可与下面的JavaScript刷新:

Could be refreshed with the following JavaScript:

$("#scores").load("index.php #scores");

这将加载的 #score 从索引中的内容,无需再次刷新整个页面。

That would load the contents of #score from index again without refreshing the entire page.

您甚至可以自动执行它使用刷新每30秒的setInterval();

You could even automate it to refresh every 30 seconds using setInterval();

var $scores = $("#scores");
setInterval(function () {
    $scores.load("index.php #scores");
}, 30000);

您可以在 $。负载() 相对=nofollow> http://api.jquery.com/load/#loading-page-fragments

You can read more about $.load() at http://api.jquery.com/load/#loading-page-fragments.

这篇关于刷新网页在PHP的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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