且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用AJAX加载外部网页的***方式

更新时间:2023-12-04 23:47:22

您可能想试试这个 JavaScript的AJAX装载机的jQuery插件,可以加载通过AJAX网页元素的含量,并改变以这样一种方式,当你点击了AJAX加载的内容的新页面元素内容中的链接,所有的链接还通过AJAX加载。

我想你可以破解它添加任何渐变过渡效果,当新的页面元素加载。

I'm not brilliant with AJAX but could somebody please write me a quick code for switching a DIV tag with an external page.

For example:

<script type="text/javascript">
// Fun Stuff Here //
</script>

<div id="random">HIDDEN</div>

<a href="externalpage.php?random=78"></a>

It would be AWESOME if the content could fade-in when it's loaded.

Ok, I have this so far (but it doesn't seem to be working):

<ul>
    <li><a href="random.html" class="load">ss3</a></li>
    <li><a href="random.php" class="load">ss4</a></li>
</ul>

<script type="text/javascript">
    $(function(){
        $("a.load").click(function (e) { 
            e.preventDefault();
            $("#folioWrap").load($(this).attr("href"));
        });
    });
</script>

<div id="folioWrap"></div>

You may want to try this JavaScript AJAX loader jQuery plugin that can load page elements content via AJAX and it alters all the links in such way that when you click on the links of the AJAX loaded content, the new page element content is also loaded via AJAX.

I suppose you can hack it to add any fade transition effects when the new page element is loaded.