开发者

Ajax refresh page content instead of div content

Is there a way to refresh the entire page conten开发者_StackOverflowt instead of just a div?


what exactly do you want here? you can write 1 javascript line to refresh entire page

 window.location.reload()


You can replace the content of the body tag. It's just like replacing the content of an ordinary div. To access the body tag use document.body or document.getElementsByTagName('body')[0].

If you do a normal page reload with window.location you will have the CSS and JavaScript in the head reloaded, so that will take more resources.


You can do something like this to send the browser to a new URL:

window.location = "http://www.google.com/"

But, at that point, you're kind of defeating the point of AJAX. Most of the time, you'd want to download only the data you need from the server, and rewrite the contents of only those parts of the page that change. It's generally a better experience for the user, that way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜