Hi,
Can anyone find why this setTimeout() loop isn't working - I'm getting:
'data_to_send' is undefined
Any help much appreciated, thanks.
BTW, ajax.js contains my handling for creating the XMLHttpRequest, called createRequest(). -
<html>
-
<head>
-
-
<script src="ajax.js" type="text/javascript"></script>
-
-
<script language="JavaScript">
-
-
function getData(data_to_send,zone_id)
-
{
-
var url = "realtime_read_values.php";
-
var req = create_request();
-
req.open("POST", url, true);
-
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
-
req.send(data_to_send);
-
req.onreadystatechange = function()
-
{
-
if(req.readyState == 4 && req.status == 200)
-
{
-
document.getElementById(zone_id).innerHTML = req.responseText;
-
//setTimeout("getData(window.data_to_send)", 3000); // this doesn't work
-
}
-
}
-
setTimeout("getData(data_to_send,zone_id)", 5000);
-
}
-
-
</script>
-
-
<body onload="getData('graph_request=graph_counter1','zone1'); getData('graph_request=graph_counter2','zone2'); getData('graph_request=graph_counter3','zone3');">
-
-
<div id="zone1">
-
waiting for data..
-
</div>
-
-
<div id="zone2">
-
waiting for data..
-
</div>
-
-
<div id="zone3">
-
waiting for data..
-
</div>
-
-
</body>
-
</html>
-
1 1192
Hi
I think , as a string type of setTimeout's 1st parameter, your parameters (data_to_send,zone_id) will not pass to the function getData. - setTimeout("getData(data_to_send,zone_id)", 5000);
you can use anonymous function to do it.
try this: - setTimeout(function(){ getData(data_to_send,zone_id); }, 5000);
Regards.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: darrel |
last post by:
I've been playing with prototype.js and scriptaculous to create some nice
drag-and-drop interaction on my applications GUI. That's working well.
Now I want to take the next step and start passing...
|
by: dmagliola |
last post by:
Hello all,
I'm experiencing a problem with ASP.Net for which I can't find a
reasonable explanation, or any information.
I'm currently developing an application that, through AJAX, asks the...
|
by: ak1dnar |
last post by:
Hi, I got this scripts from this URL
There is Error when i submit the form.
Line: 54
Error: 'document.getElementbyID(....)' is null or not an object
What is this error.
Complete Files
|
by: nghivo |
last post by:
I attempted to synchronize async Ajax calls using the following JS blocks:
====================================================
function getXMLHTTPRequest()
{
try
{
req =...
|
by: MikeB |
last post by:
Hello All, I am new to ajax and wanted to start by trying something simple.
I have a web form with an updatepanel and then inside the update panel I
have a listbox. Then outside of the updatepanel...
|
by: sheldonlg |
last post by:
I came across a problem and googling for an answer didn't help.
What I want to do is run an AJAX script that sets a hidden variable on
the form. I call the AJAX script from a javascript...
|
by: Bryan A |
last post by:
Is there a way to add a timeout to this script so that it times out at
a certain time. So it would be auto updating every 2seconds and it
would timeout like after 100 seconds with a message?.
...
|
by: Chris |
last post by:
I'm developing an ASP.NET Page that processes some files, does some
things to them. I'd like to have a gridview that displays each file,
and it's status, if it's done processing, still processing,...
|
by: javediq143 |
last post by:
Hi All,
This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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
|
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...
| |