473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to refresh the page not manually

hi guys

i write a code to automatic refresh using ajax

but not working fine.
[HTML]<html>

<head>
<script type="text/javascript">
function Ajax(){
var xmlHttp;
var res;
try{
xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!?");
return false;
}
}
}

xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
//res=document.getElementById('ReloadThis').innerHTM L=xmlHttp.responseText;
res=xmlHttp.responseText;
document.write(res);
setTimeout('Ajax()',500);
}
}
xmlHttp.open("GET","view.jsp",true);
xmlHttp.send(null);
}

window.onload=function(){
setTimeout('Ajax()',500);
}
</script>
</head>

<body>
</body>
</html>
[/HTML]
give the help na
by
Naga
Dec 26 '07 #1
4 1489
gits
5,390 Expert Mod 4TB
you should avoid document.write that destroys your current document-tree when the callback called the first time ...

kind regards
Dec 26 '07 #2
dmjpro
2,476 2GB
hi guys

i write a code to automatic refresh using ajax

but not working fine.
[HTML]<html>

<head>
<script type="text/javascript">
function Ajax(){
var xmlHttp;
var res;
try{
xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!?");
return false;
}
}
}

xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
//res=document.getElementById('ReloadThis').innerHTM L=xmlHttp.responseText;
res=xmlHttp.responseText;
document.write(res);
setTimeout('Ajax()',500);
}
}
xmlHttp.open("GET","view.jsp",true);
xmlHttp.send(null);
}

window.onload=function(){
setTimeout('Ajax()',500);
}
</script>
</head>

<body>
</body>
</html>
[/HTML]
give the help na
by
Naga
Ajax is for just to update the a little bit portion.
But if the maximum portion to be updated then you better to refresh the page.
And the code for it using JS.

Expand|Select|Wrap|Line Numbers
  1. winodw.location.reload(true);
  2.  
Debasis Jana
Dec 26 '07 #3
Suggestion:
change

Expand|Select|Wrap|Line Numbers
  1. document.write(res);
to

Expand|Select|Wrap|Line Numbers
  1. document.getElementById('result').innerHTML=res;
  2.  
and somewhere in the page have

[HTML]<div id="result"></div>[/HTML]
Dec 26 '07 #4
yah working fine thank you
Dec 27 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Charles Soto | last post by:
I've got a main loop script that calls two other scripts that do no user interaction. All they do is send a couple of mysql update statements. Then they use header() to call the main loop again. ...
10
by: Conax | last post by:
Hi there, My boss is hoping that I can come up with a page that displays some information. The information will always be displayed on specific part of the page, with auto refresh. But he...
0
by: Conax | last post by:
Hi, It's me again asking about IFRAME. With UncleWobby, Steven Burn and Roland Hall's help, I was able to create a proper IFRAME section on my page. Now I come to the next problem. I'd...
2
by: Gary \(Girish\) | last post by:
Hello: I am using SA-FileUp to enable members to upload their product images to my ISP sever. When member uploaded a new image file, the file name is replaced with the member ID and the old file...
2
by: Prodip Saha | last post by:
I am sure there is an easy fix for this problem. I am reloading the same page at an interval using the meta refresh tag in aspx page. This page has one textbox and one button. The problem is -when...
4
by: Coleen | last post by:
Hi All :-) I have a web page that I need to refresh every time the page loads. I thought that the page automatically did a refresh/postback on the Page_Load event. Isn't refreshing the page the...
8
by: Jason S | last post by:
Hi, is there any way of getting my VB (6.0) program to automatically 'Refresh' an IE window that might be active (window status not applicable). It needs to be able to determine which active IE...
10
by: phforum | last post by:
Hi, I wrote a PHP page for user input the information to search the database. And the database data will update every second. I want to set the auto refresh to get the data from database every...
3
by: Ned Balzer | last post by:
Hi all, I posted this question some time ago in an earlier thread but so far I still don't have an understanding of why this is happening or what I can do to fix it. I use Session variables,...
35
by: Kaante | last post by:
Hi, i want a frame on my website to display one pic if the user has new messages and another different pic if it dsnt. Before i used html to auto refresh page every 10 secs. that was annoying...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.