[英]Only reload a part of a web page
I have a page in which a user is asking a question after watching video. 我有一个页面,用户在观看视频后正在提问。 I want to update the number of questions asked as soon as any user asks question. 我想在任何用户提出问题后立即更新提出的问题数量。 I do not want to reload the whole page. 我不想重新加载整个页面。 I only want to update that specific div which is containing all questions. 我只想更新包含所有问题的特定div。
You can use jQuery.load()
for this. 您可以jQuery.load()
使用jQuery.load()
。
For example, wherever you want to refresh some div with id= questions
, you do this: 例如,无论您想在哪里刷新带有id = questions
div,都可以这样做:
jQuery('#questions').load('/some_url #questions > *');
You add a page to you server which returns only your questions. 您将一个页面添加到服务器,该页面仅返回您的问题。
eg your full page contains 例如,您的整个页面包含
<div id="questions"></div>
then you design a page /questions.php on your server which returns only what is supposed to be in that div 然后在服务器上设计一个页面/questions.php,该页面仅返回该div中应该包含的内容
with jquery.load you fill the questions div 用jquery.load填充问题div
<script>$(function(){ $("#questions").load("/questions.php") })</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.