Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4123100
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:34:04+00:00 2026-05-20T23:34:04+00:00

My whole page is loading again whenever I make a ajax call to load

  • 0

My whole page is loading again whenever I make a ajax call to load a div.
I have noticed that ‘body onload=init()’ onload event is getting triggered on ajax response and all the initialization is happening again. I don’t want that to happen.
Is there a way by which only div is loaded through ajax call.

<body onload="init()">
.....
.....
<div>...<a href="" onclick="saveView('more')"><b>More</b></a></div>
</body>

main.js

function saveView(arg){
    if(arg=="more"){
            ajaxGet(baseRef+"all.html", loadList);

    }else{
            ajaxGet(baseRef+"all-A.html", loadList);

    }
function init(){
.....
}

function ajaxGet(url, responseHandler)
{
    var page_request = false;

    if (window.XMLHttpRequest && !(window.ActiveXObject && window.location.protocol == "file:")) { 
                // use this only if available, and not using IE on a local filesystem
        page_request = new XMLHttpRequest();
        }
    else if (window.ActiveXObject) { // older versions of IE, or IE on a local filesystem
        try {
            page_request = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e){
            try{
                page_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e){
            }
        }
    }
    else {
        alert("Your browser does not support XMLHTTP.");
        return false;
    }


    page_request.onreadystatechange=function() {
        if(page_request.readyState==4) {
                        // on local machines the status for success is 0. on web servers it is 200
            if(page_request.status==200 || page_request.status==0) {
                responseHandler(page_request);
            }
        }
    }

    page_request.open('GET', url, true);
    page_request.send(null);
}

function loadList(page_request){
    document.getElementById("list").innerHTML=page_request.responseText;
    Loaded = true;    
    try{
        if(pLoaded) 
            doFilterStateChange1();
        }catch(e)
        {
        }
    setTimeout("restoreScrollTop()", 1000);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:34:05+00:00Added an answer on May 20, 2026 at 11:34 pm

    It is not ajax that is triggering onLoad event of body.
    If you see the anchor tag, I haven’t assigned any value to href=”” which was causing the page to be loaded again. Removing it solved the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My HTML markup looks like that <html> <body> <div id=loading><img src=core/design/img/load/load.gif /></div> <div id=wrap></div>
I am new to jQuery / AJAX. I have a page that uses colorbox
On the first page I have this function: <script> function update() { $(#notice_div).html('Loading..'); $.ajax({
I want to show a div with a loading animation over my page while
I have a page that has the following php: <?php $mail = $_GET[mail]; if
I have an app whose first page is simply a image with loading symbol.
Ok, so I have a whole page hide / fadeIn effect happening with jQuery.
i have a general question : is loading data via Ajax totally faster than
I have a page where while the page loads, I put an absolute DIV
I have an asp.net view/page (dynamic) that is built up of nested Html.RenderPartials. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.