微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jQuery.post()里面的一个jQuery.post()

想象一下,通过使用jQuery .post()(或.get())的菜单加载内容的网站.

想象一下,在这个动态加载的内容里面应该是另一个jQuery的帖子来显示一些更多的内容

(全部不导航到地址栏中的新文件)

这是我的意思(但只有基础框架…):

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input type="text" name="n" id="n" placeholder="Search..." />
<button id="click1">Go</button>
<!-- the result of the search will be rendered inside this div -->
<br />
<div id="result" name="result"></div>

<script>
window.onload = (function(){
    /* attach a submit handler to the button */

    $("#click1").click(function(event) {
        $.ajax({
            url: 'test.PHP',type: 'POST',data: 'n: term',success: function(msg) {
                $( "#result" ).empty().append( msg );
              }
         });
    });
});
</script>

</body>
</html>

所以,停止笑,我知道这个页面只能加载在div中,而且这不是因为相同的ID而工作的…这是not Inception here

原文地址:https://www.jb51.cc/jquery/176672.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐