HighDots Forums  

Probably covered somewhere but... ajax to variable...???

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Probably covered somewhere but... ajax to variable...??? in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tym
 
Posts: n/a

Default Probably covered somewhere but... ajax to variable...??? - 01-19-2009 , 09:48 AM






OK - i'll admit it, only just started with javascript and Ajax today but
hey! got to start somewhere!!

Been playing with php for a while too so I'm not a complete nubie!

I've got a test ajax situation whereby it executes evey few seconds to
update the screen from something in the database...

the php script returns the number of rows in the releveant table (count(*))
and this is displays in the correspoding <div> secontion on the html page

Great!!

however...

What I really want to do is have the jaavascript part of my html page look
at the number returned by the php script and compare it to the value it last
returned. Only if the new value is bigger than the previous one, will the
<div> be updated by another php script.

in simple (vb!) terms:

b = 0
a = value returned from script.php
do
if (a>b ) then
run script2.php - update <div> with new data
b=a
endif
loop

can I do this with javascipt and ajax??

Tym.



Reply With Quote
  #2  
Old   
Tym
 
Posts: n/a

Default Re: Probably covered somewhere but... ajax to variable...??? - 01-19-2009 , 09:50 AM







"Tym" <spamtrap (AT) ictis (DOT) net> wrote

Quote:
in simple (vb!) terms:

b = 0
a = value returned from script.php
do
if (a>b ) then
run script2.php - update <div> with new data
b=a
endif
loop

That do...loop is probably a bad example.... what my html page uses is:

var RecordCount = function()
{
new loadXmlHttp('ajax2.php', 'timeDiv');
setInterval(function(){new loadXmlHttp('ajax2.php', 'timeDiv');}, 1000);
}





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.