javascripthtmlx-http-method-override

Loading a page with xhttp


I have a little question that I want to ask.

First of all, I'm using JS for loading a page.

function ReLoad() {
      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function () {
         if (xhttp.readyState == 4 && xhttp.status == 200) {
             document.getElementById("box").innerHTML = xhttp.responseText;
          }
       };
      xhttp.open("GET", "calc/index.html", true);
      xhttp.send();
 }

Now, My problem is while I'm inserting this index into the main page, because the page auto-scroll immediately to the start and I want to load the page without this annoying effect.

Please, Can someone help me? Thanks


Solution

  • I finally solved it adding this to the end of the code:

    e.preventDefault();
    return false;