最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Only reload a part of a web page - Stack Overflow

programmeradmin3浏览0评论

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.

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.

Share Improve this question edited Sep 13, 2012 at 5:36 Daedalus 7,7225 gold badges38 silver badges63 bronze badges asked Sep 13, 2012 at 5:30 ShailendraShailendra 5672 gold badges5 silver badges11 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

You can use jQuery.load() for this.

For example, wherever you want to refresh some div with id=questions, you do this:

jQuery('#questions').load('/some_url #questions > *');

You add a page to you server which returns only your questions.

e.g. 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

with jquery.load you fill the questions div

<script>$(function(){  $("#questions").load("/questions.php")  })</script>
发布评论

评论列表(0)

  1. 暂无评论