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

  • Home
  • SEARCH
  • 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 6545675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:36:53+00:00 2026-05-25T11:36:53+00:00

im trying to get a bit of html to refresh every 1 second with

  • 0

im trying to get a bit of html to refresh every 1 second with AJAX, I made this code my self with bits from different websites that I found. Im trying to understand how it all works.

I want to be able to refresh the page without reloading it in the browser and I want the JS function AJAXdisplay(); to run every one second with the variables I send to AJAXreturn(); when I call it.

When I call AJAXreturn(); I want it to run AJAXdisplay(); once to print out the html from my php file, on my body if the index file I want somthing like this

 <body onClick=:AJAXdisplay(same variables as used when the page was made);">             

</body>    

here is my code:

function getHTTPObject(){
if (window.ActiveXObject) {
    return new ActiveXObject("Microsoft.XMLHTTP");
}
if (window.XMLHttpRequest){
    return new XMLHttpRequest();
}
else {
    alert("Your browser does not support AJAX.");
    return null;
}
}   

function AJAXsend(url) {
httpObject = getHTTPObject();
if (httpObject != null) {
    httpObject.open("POST",url);
    httpObject.send(null);
}
}

function AJAXreturn(url,pageName){
httpObject = getHTTPObject();
if (httpObject != null) {
    if (navigator.appName != "Microsoft Internet Explorer") {
        history.replaceState("", "", "index.php?page=" + pageName)
    }
    httpObject.open("POST",url);
    httpObject.send(null);
    AJAXdisplay(httpObject,url,pageName);
}
}

function AJAXdisplay(httpObjectIn,urlIn, pageNameIn){
httpObjectIn.onreadystatechange = function(){
    if(httpObjectIn.readyState == 4){
        document.getElementById('outputHTML').innerHTML = httpObjectIn.responseText;
        AJAXdisplay('function(httpObjectIn,urlIn,pageNameIn)',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-25T11:36:53+00:00Added an answer on May 25, 2026 at 11:36 am

    To make javascript refresh, you should use the setInterval(); function. Here’s what your looking for:

    var timer = setInterval ("AJAXdisplay(variable);", 1000);
    

    And if you ever need to stop the refresh you use:

    clearInterval (timer); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get all css link from html like this segment of
I'm trying to get the following bit of code to work in LINQPad but
I am trying to get the DB2 data provider from a 32-bit .Net application
I'm trying to get the hang of jQuery and I had this simple bit
I'm trying to get the pixel rgb values from a 64 x 48 bit
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
I'm trying to get a page to refresh when navigated to from the back
I'm having a bit of trouble trying to get class variables to work in
I'm trying to get a better understanding of how Windows, 32-bit, calculates the virtual
I am a bit puzzled with my Regex results (and still trying to get

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.