刷新部分页面(div) [英] Refresh Part of Page (div)

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

问题描述

我有一个附加到java程序的基本html文件。这个Java程序在页面刷新时更新HTML文件的一部分内容。我想在每个时间间隔后只刷新页面的那一部分。我可以将我想要刷新的部分放在div中,但我不确定如何只刷新div的内容。任何帮助,将不胜感激。谢谢。

解决方案

使用Ajax进行此操作。通过ajax获取当前页面,但不是整个页面,只是服务器上的div。然后,数据将(再次通过jQuery)被放入相同的div中,并用新的内容替换旧内容。



相关函数:

http://api.jquery.com/load/ p>

eg

  $('#thisdiv')。 URL +'#thisdiv'); 

请注意,加载会自动替换内容。请确保在ID选择器之前包含空格。


I have a basic html file which is attached to a java program. This java program updates the contents of part of the HTML file whenever the page is refreshed. I want to refresh only that part of the page after each interval of time. I can place the part I would like to refresh in a div, but I am not sure how to refresh only the contents of the div. Any help would be appreciated. Thank you.

解决方案

Use Ajax for this.

Build a function that will fetch the current page via ajax, but not the whole page, just the div in question from the server. The data will then (again via jQuery) be put inside the same div in question and replace old content with new one.

Relevant function:

http://api.jquery.com/load/

e.g.

$('#thisdiv').load(document.URL +  ' #thisdiv');

Note, load automatically replaces content. Be sure to include a space before the id selector.

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

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