Load html content in div

29,008

Solution 1

You are not calling the function check() anywhere.

Try this:

...
<script>
function check() {
    $( "#revw" ).load('review_list.html #target');
}
$(document).ready(function() {
    check(); // call the function
});
</script>
...

Solution 2

Try this using $.get.

 $(document).ready(function() {
    $.get('review_list.html')
             .success(function(data) {
                 $('#revw').html(data);
             });
    });

Your HTML page

<div id='test'>
 Load this content to the id="revw" div.
</div>
Share:
29,008
Sowmya
Author by

Sowmya

UI Developer with 6 years of experience.

Updated on July 17, 2022

Comments

  • Sowmya
    Sowmya almost 2 years

    I am trying to load the content from another html file into my existing html file using jquery .load

    But unfortunately it is not loading the content.

    Please suggest me with the proper solution.

    Here is my existing html and jquery to load content from external HTML file

        <!DOCTYPE html>
        <html lang="en">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Review</title>
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        </head>
        <body>
                <ul class="reviews" id="revw">
    
                </ul>
        </div>
        <script>
        function check(){
    $( "#revw" ).load( "review_list.html #test" );
    }
        </script>
        </body>
        </html>
    

    Page from which we need to load the content

    <html>
    <head></head>
    <body>
    <div id='test'>
     Load this content to the id="revw" div.
    </div>
    </body>
    </html>