I've been trying to play around with this, my javascript knowledge is
very limit still (learning!).
I keep getting this error:
Error: useless setInterval call (missing quotes around argument?)
I changed the script after running it a bit, to try and fix the error,
still having problems:
$(document).ready(function() {
var date_reg = $("input#date_requested").val();
var counter = -1;
slideTimer = setInterval((function(date_reg,counter){ //global var
if (counter <= date_reg) {
$('#result').load('/get_time_lapse.pl',
{date_requested: date_reg});
counter++;
date_reg--;
} else { clearInterval(slideTimer); }
})(date_reg,counter),2000);
});
On Nov 16, 1:04 pm, ricardobeat <[EMAIL PROTECTED]> wrote:
> There is no 'delay' or 'pause' in Javascript, you have to use a
> timeout or interval. Maybe this will work (interval, vars passed with
> a closure, if instead of while):
>
> $(document).ready(function() {
>
> var date_reg = $("input#date_requested").val();
> var counter = -1;
> slideTimer = setInterval((function(date,counter){ //global var
> if (counter <= date) {
> $('#result').load('/get_time_lapse.pl',
> {date_requested:date});
> counter++;
> date--;
> } else { clearInterval(slideTimer); }
> })(date_reg,counter),2000);
>
> });
>
> - ricardo
>
> On Nov 16, 3:22 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Hello,
>
> > I'm trying to fetch some data from a Perl script and have it begin to
> > display as many times as there is data. More or less a "data"
> > slideshow. The data is actually very visual, but at the moment, i dont
> > want to implement a pause, forward/backward option, until I get the
> > automatic option working.
>
> > Basically what I'm trying to do is have the content load, wait, load,
> > wait, etc....With a reasonable 2 - 3 seconds between each load...Here
> > is the code I have that isn't quite working:
>
> > $(document).ready(function() {
> > var date_reg = $("input#date_requested").val();
> > var counter = -1;
> > while (counter <= date_reg)
> > {
> > $("#result").load('/get_time_lapse.pl',
> > {date_requested:
> > date_reg});
> > counter = counter + 1;
> > date_reg = date_reg - 1;
> > }
> > });
>
> > where date_reg is just the number of times I want to load the screens.
> > However, if I look at the logs for my Perl script, it does say all 10
> > calls, immediately, as fast as it can. I've tried to put a javascript
> > pause or whatever that function was called in here, but it doesnt seem
> > to work.
>
> > Any suggestions to implement a pause between each .load?
>
> > Thanks