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 9037853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:20:37+00:00 2026-06-16T09:20:37+00:00

I want to refresh a part of the webpage automatically without refreshing the whole

  • 0

I want to refresh a part of the webpage automatically without refreshing the whole page. (say one division of webpage).

I have a script that calls a PHP page periodically.

Script:

<!----------- ********* AJAX code to auto refresh the part of a webpage************ --------->
<script langauge="javascript"> 
  function loadXmlHttp(url, id) {
    var f = this;
    if (loadXmlHttp.xmlHttp){
      f.xmlHttp = loadXmlHttp.xmlHttp();
      f.el = document.getElementById(id);
      f.xmlHttp.open("GET", url, true);
      f.xmlHttp.onreadystatechange = function(){f.stateChanged();};
      f.xmlHttp.send(null);
    } else {
      alert('Your browser does not support AJAX!');
    }
  }
  loadXmlHttp.xmlHttp = null;
  loadXmlHttp.re = /^http/.test(window.location.href);
  /*@cc_on @*/ // used here and below, limits try/catch to those IE browsers that both benefit from and support it
  /*@if(@_jscript_version >= 5) // prevents errors in old browsers that barf on try/catch & problems in IE if Active X disabled
  try {loadXmlHttp.ie = window.ActiveXObject}catch(e){};
  end @*/
  if (window.XMLHttpRequest && (!loadXmlHttp.ie || loadXmlHttp.re))
    loadXmlHttp.xmlHttp = function(){return new XMLHttpRequest();}; // Firefox, Opera 8.0+, Safari, others, IE 7+ when live - this is the standard method
  else if (/(object)|(function)/.test(typeof createRequest))
    loadXmlHttp.xmlHttp = createRequest; // ICEBrowser, perhaps others
  else {
    loadXmlHttp.xmlHttp = null;
    // Internet Explorer 5 to 6, includes IE 7+ when local //
    /*@if(@_jscript_version >= 5)
    try{loadXmlHttp.xmlHttp = function(){return new ActiveXObject("Msxml2.XMLHTTP");};}
    catch(e){try{loadXmlHttp.xmlHttp = function(){return new ActiveXObject("Microsoft.XMLHTTP");};}catch(e){}}
    @end @*/
  }
  loadXmlHttp.prototype.stateChanged = function(){
    if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !loadXmlHttp.re)){
      this.el.innerHTML = this.xmlHttp.responseText;
      if(this.success){
        this.success();
      }
    }
  }
</script>
<!----------- ********* AJAX code to auto refresh the part of a webpage ends here************ --------->

And a Div where I am calling this function is something like this:

<div class="textad" id="text"></div>
  <script type="text/javascript">
    (function(){
      var statsrequest = new loadXmlHttp('display_text_ad.php', 'text'), repeat = arguments.callee;
      statsrequest.success = function(){setTimeout(repeat, 6000);};
    })();
  </script>
</div>

Now, this code is working fine with all browsers except Internet Explorer. (I have checked for Chrome, Mozilla, Opera and Safari). So, I need a little help fixing this bug with Internet Explorer. Any help will be appreciated. Thanks in advance.

  • 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-06-16T09:20:38+00:00Added an answer on June 16, 2026 at 9:20 am

    The problem is that your initial IE conditional compilation script is missing an ‘@’ character. The end @*/ line should instead be @end @*/.

    It should be pointed out, however, that using JScript version browser detection is not a good practice. A simpler, more robust approach would be to directly test for the standards you want to use and fall back to workarounds for legacy browsers. For example:

    if (window.XMLHttpRequest) {
        // Use native XHR object for modern browsers
        loadXmlHttp.xmlHttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // Use the ActiveX control for legacy browsers
        loadXmlHttp.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else {
        // No XHR mechanism is available.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to refresh only a single part of my page not the whole.
I want to refresh Google Map and send new geolocalization request without refreshing the
I want to submit a form without page refresh using jQuery. I found some
What I want is to have links which change a part of the page
I want to refresh an XHTML page (jsf) or part of this page, when
I have a form with one text box that is part of a div
I have couple of formulas and data coming from database. I want to refresh
I am very new to ajax concept,I want to submit a form without refresh
I have a simple MVC 3 application. I want the site to automatically redirect
I have a simple form with one input. The page is located here: Actual

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.