开发者

Loading multiple views from codeigniter using jquery

    <script type="text/javascript">
$(document).ready(function() {
        $('a.menuitem').click(function() {
                            var link = $(this), url = link.attr("href");
                                var newDiv = '<div></div>';
                                $("#content_pane").append(newDiv);
                                newDiv.load(url);
                                return false; // prevent default link-behavior
                    });

 });
   </script>
</head>
<body>
    <li><a class="menuitem" href="inspiration">Inspiration</a></li>
    <li><a class="menuitem" href="blog">Blog</a&开发者_开发问答gt;</li>
    <div id="content_pane">

    </div>
</body>
</html>

The above code is semi working, when I click the button a new div id created but it prints out load(url) on the page instead of showing the page content that it is supposed to be loading does any one have any tips?


Try this:

var link = $( this ), url = link.attr( "href" );
var newDiv = $( document.createElement( 'div' ) );
$( "#content_pane" ).append( newDiv );
newDiv.load( url );
return false;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜