开发者

Loading multiple views from codeigniter using jquery

开发者 https://www.devze.com 2022-12-12 23:56 出处:网络
<script type=\"text/javascript\"> $(document).ready(function() { $(\'a.menuitem\').click(function() {
    <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

精彩评论

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