Menu Close

How to send an Ajax request after the page has loaded


Let’s see how to send an Ajax request after the web page has loaded.

Here, the ajax request performs to get the data from the url. Then it manipulates the data to the given id and loads the page successfully. If anything is wrong in the given url it will display the error message.


        <meta charset="UTF-8">
        <title>Ajax Call After Page Load</title>
        <!-- Content is blank by default -->
        <div id="content_blank"></div>
        <script src=""></script>

        //When the page has loaded.
        $( document ).ready(function(){
            //Perform Ajax request.
                url: 'test.html',
                type: 'get',
                success: function(data){
                error: function (xhr, ajaxOptions, thrownError) {
                    var errorMsg = 'Ajax request failed: ' + xhr.responseText;
Posted in Ajax, HTML

You can also read...