简体   繁体   English

jQuery和Ajax动态加载新页面

[英]jQuery and Ajax to dynamically load new page

I am attempting to create a static microsite that has a list of pages. 我正在尝试创建一个具有页面列表的静态微型网站。 I have a main file 'index.php' with a list of links like the following: 我有一个主文件“ index.php”,其中包含如下链接列表:

<a href="/pages/page1.php">Go to page 1</a>

<a href="/pages/page2.php">Go to page 2</a>

What I'm trying to do is something like ( http://voiceandtone.com/ ) where when you click on a page it fades-out the current page you are on and animates in the new page without refreshing the page. 我想做的是类似( http://voiceandtone.com/ )的东西,当您单击页面时,它会淡出您当前所在的页面,并在不刷新页面的情况下为新页面添加动画效果。

Does anyone know how I can achieve this or if there are any great tutorials out there that can help me? 有谁知道我如何实现这一目标,或者是否有任何出色的教程可以帮助我?

Maybe somethig like this ? 也许像这样吗?

$(document).ready(function() {
    $("a").click(function() {
         $('#result').load("http://domain.com" + $(this).attr('href'), function(){
            // Stuff to do after the page is loaded
         });
    });
});

here is documentation http://api.jquery.com/load/ 这是文档http://api.jquery.com/load/

The answer is Ajax. 答案是Ajax。 You can use either the GET or POST method to achieve your task. 您可以使用GETPOST方法来完成任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM