小编Seb*_*eba的帖子

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>
Run Code Online (Sandbox Code Playgroud)

所以,别笑了,我知道页面只在div中加载自己,因为ID相同而无法正常工作......这不是Inception ;-) …

html ajax jquery post load

10
推荐指数
1
解决办法
4068
查看次数

标签 统计

ajax ×1

html ×1

jquery ×1

load ×1

post ×1