我要的刷新整个页面使用Ajax,点击一些初步的站点链接后。
I want to refresh a full page with ajax, after clicking on some initial site link.
示例:
我们已经打开网站www.love.com,它有一个链接,www.love.com/somepage.html~~V
We have opened site www.love.com, it has a link to www.love.com/somepage.html
在我们点击这个链接,整版必须用AJAX(由somepage.html代替活动页面)刷新
After we click on this link, full page must be refreshed with ajax (replaced active page by somepage.html)
和存在必须有一些淡入/淡出效果,当页面被替换。
And there is must be some fadeIn/Out effect, when the page is replaced.
如何?
也许有些插件可以做到这一点,任何一个环节?
maybe some plugin can do this, any link?
好样的一个整版的要求相矛盾AJAX的目的,
Well a full-page request kind of contradict the purpose of AJAX,
但如果你坚持:) 你可以使用一个巨大的股利为你的页面的占位符,使用jQuery负载/阿贾克斯
but if you insist :) you can use a huge div as a placeholder of your page, and use jQuery Load/Ajax
在div是这样
<div id="yourhugediv"></div>
和您可以使用功能
function changeUrl(href)
{
$('#yourhugediv').load(href);
href = (href == "") ? "/" : href;
uri = window.location.href.split("#/");
window.location.href = uri[0] + "#/" + href;
}
手动添加的功能,你的链接
either manually add the function to your link
<a href="#" onclick="changeUrl('http://love.com/somepage.html')">to load</>
或使用jQuery选择遍历每个锚
or use jQuery selector to iterate every anchor
$('a').click(function()
{
changeUrl(a.attr('href'));
});
$('a').attr('href','#');