[nycphp-talk] the stale V in MVC web apps
David Mintz
vtbludgeon at gmail.com
Wed Mar 4 14:42:49 EST 2009
On Wed, Mar 4, 2009 at 1:30 PM, John Campbell <jcampbell1 at gmail.com> wrote:
> On Wed, Mar 4, 2009 at 12:48 PM, David Mintz <vtbludgeon at gmail.com> wrote:
> > // on load
> >
> > window.updater = window.setInterval(submitForm,updateInterval);
> >
> > // and...
> >
> > submitForm = function(){
> >
> > $('searchForm').request({
> >
> onCreate:function(response){$('formSubmit').value="Processing..."},
> >
> > onComplete:function(xhr){
> > // reset timer
> > window.clearInterval(updater);
> > window.updater =
> window.setInterval(submitForm,updateInterval);
> > $('formSubmit').value="Search" // reset button's
> value
> >
> > // etc
> >
> > }
> > });
> >
> > };
>
> I don't think your code is quite right. To validate polling code,
> just add "sleep(2)" to your php code, and set the updateInterval to 1
> second. If it doesn't work under these conditions, then the code is
> not quite right.
Why would you want to sleep() on the server side?
In any case, the updateInterval is currently 5000 milliseconds. I just want
to make sure their snapshot never gets more than five minutes old. For this
application I don't think it's essential to update every 3 seconds.
>
>
> The problem with your code is that you clear the interval onComplete,
> rather than onCreate. It is possible that the interval keeps firing
> while onComplete has not been run because the ajax requests are taking
> a long time due to a network issue.
Got it.
>
> To fix it... just change setInterval to setTimeout everywhere, and get
> rid if the clearInterval code.
Right... thank you very much.
--
David Mintz
http://davidmintz.org/
The subtle source is clear and bright
The tributary streams flow through the darkness
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090304/3f49894c/attachment.html>
More information about the talk
mailing list