;

PDA

Click to See Complete Forum and Search --> : interval to update


hansverst
11-08-2006, 11:42 AM
Hello,
i have a question, i try a lot but how can i simple update from a url?
I use a simple perl file that sends data (text) separated ' ; ' for every new line (for the test it shows local time and ip)
I try the code below local, and it updates it self nice, so every 5 sec i saw new updated text.
But when i use the url from the hosted server it only loads ones, then only it repeat his own text in message.text.
Is there a way to to get this right ?
Thank you,
Hans

/ *** create output field ***

myTextFormat = new TextFormat();
myTextFormat.font = "Verdana, Helvetica";
myTextFormat.size = 12;
myTextFormat.color = 0x000000;

createTextField("message",1,23,49,564,258);
message.border = false;
message.background = false;
message.multiline = true;
message.wordwrap = true;
message.scrolbar = true;
message.setNewTextFormat(myTextFormat);

lv = new LoadVars();

update= function (){
lv.load('http://www.screensave.nl/get.pl');
}

lv.onData = function(src){
records = src.split(';');
for (var b = 0; b < records.length; b++){
message.text=message.text+records[b]+'\n';
}
}

setInterval(update, 5000);
update();

swrzzzz
11-08-2006, 11:59 AM
its not necessarily the problem, but sometimes things get cached.

When I read dynamic data I always put

"?random="+math.random()

at the end of the url. This makes the browser think you are asking for a response and makes it make a new request each time

Steve

hansverst
11-09-2006, 06:09 AM
Hello swrzzzz,
thanks for your answer.
I did try to put the code at the end of the url, you wrote but still not working well, so i try this code now, and now it update great.
i don't know if this is a good one to use to update data but i think it is.
Thank you,
Hans

update= function (){

_root.loadVariables("http://www.screensave.nl/get.pl", "POST");
records = i.split(';');

for (var b = 0; b < records.length; b++){
message.text=message.text+records[b]+'\n';
}
i = "";
_level0.message.scroll += 15;_level0.dwn = 1;
}

setInterval( update, 3000, );
update();

swrzzzz
11-09-2006, 07:52 AM
OK

It's cool that you got it working and it was obviously a caching issue.

I just noticed a typo in my reply -it should have been Math.random (capitalised) and it wouldn't have worked if you just copied in the text:-(

Sorry

Steve