1

Is it possible reload a page without refresh (silently) ? Here is an example where page reload automatically. But you can easily see that the page is refreshing after certain time interval. I don't like this where end user is getting such experience. I want that the page reload but without refreshing. End user should not feel that page is refreshing. Is it possible using simple html? or jquery?

I don't want <META HTTP-EQUIV="refresh" CONTENT="5"> or setTimeout of jquery because it refreshes the page while reloading?

jjmontes
  • 24,679
  • 4
  • 39
  • 51
no-reload
  • 11
  • 1

2 Answers2

0

Don't reload the whole page. Just use ajax to reload the components that needs to be updated. jQuery is perfect for that.

Voooza
  • 749
  • 4
  • 8
0

Use a setInterval with an ajax request. I'll update in 1 min with the script.

var divid = 'yourDivsId'

function createRequestObject() 
{
  var obj;
  var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
    obj = new ActiveXObject("Microsoft.XMLHTTP");
  }else{
    obj = new XMLHttpRequest();
  }
  return obj;
}

function sendReq(req) 
{   
  http.open('get', req);
  http.onreadystatechange = handleResponse;
  http.send(null);
}

function handleResponse() 
{   
  if (http.readyState == 4)
  {
    var response = http.responseText;
    document.getElementById(divid).innerHTML=response;
  }
}


var http = createRequestObject();
setInterval('yourUrl', 30000); //or whatever time you want.

Should do the trick.

zozo
  • 8,230
  • 19
  • 79
  • 134