aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes dynamic xmlhttp page Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "dynamic xmlhttp page" Watch "dynamic xmlhttp page" New topic
Author

dynamic xmlhttp page

Tien-Chih Wang
Greenhorn

Joined: Feb 23, 2003
Posts: 25
Hi,
I trigger two xmlhttp connection simultaneously.
What I need is to keep one xmlhttp.responseText as static InnerHtml and still updating the other(Using setTimeout()). The page only displays the setTimeout() one but never shows the first static one. Is there anyway to do this? Sample codes provided will be appreciated.

Regards,

Tien-Chih Wang
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
What is the code that you are using?

Eric
Tien-Chih Wang
Greenhorn

Joined: Feb 23, 2003
Posts: 25
Hi,

here is the xmlhttp javascript source code. The 'count' element keeps counting without any problem, but the 'record' element never show up.
---------------------------------------------------------------------------

<script language="javascript">
<!--

function count()
{
req = new ActiveXObject("Microsoft.XMLHTTP");
req.open("get", "counter.cgi", true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.onreadystatechange=
function()
{
if (req.readyState==4)
{
if (req.status==200)
{
window.document.getElementById('count').innerHTML=req.responseText;
}
}
};

req.send();
setTimeout("count()",500);
}


function call()
{
req = new ActiveXObject("Microsoft.XMLHTTP");
req.open("get", "jobHandling.cgi", true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.onreadystatechange=
function()
{
if (req.readyState==4)
{
window.document.getElementById('record').innerHTML=req.responseText;
}
};

req.send();
count();
}

---------------------------
Html code

<table>
<tr><td><div id='count'></div></td></tr> // Display ok
<tr><td><div id='record'></div></td></tr> // Show Nothing..:-(

Regards,

Tien-Chih Wang
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
I glanced at it in a split second and you are using two global variables named req. if you do not declare var req inside your function, it is global. Try declaring it and see if you still have problems. I did not look at the code other than that right now.

Eric
Tien-Chih Wang
Greenhorn

Joined: Feb 23, 2003
Posts: 25
Hi,
Thanks for the help!! Indeed it's a global variable issue.
Take a look at this site to see the result.

http://www.onsofts.com/deepJobSearch.jsp

Sincerely,

Tien-Chih Wang
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
Glad I could help.

Eric
Tien-Chih Wang
Greenhorn

Joined: Feb 23, 2003
Posts: 25
Originally posted by Tien-Chih Wang:
Hi,
Thanks for the help!! Indeed it's a global variable issue.


Sincerely,

Tien-Chih Wang
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: dynamic xmlhttp page
 
Similar Threads
Can javascript files shared variables across multiple instances of an application
How to find whether URL is active or not using javascript?
Javascript call AFTER redirect?
responseXml is null
Session Time out Message issue using SetTimeout