I hope Javascript questions are welcome here. There's no "Javascript Megathread", and this question is very very simple, so I didn't want to start a new thread just for it. I'm very new to Javascript (Perl's my language of choice), but I'm writing a web-app using Perl's CGI::Ajax, which enables Ajax by mapping Javascript functions on your web page to Perl functions. Anyhoo, the Javascript functions need to have their parameters sorted in a particular way for CGI::Ajax. I'm having problems with this... so I'm hoping you guys can help me. code:
In my example, I need to feed the following list of parameters into the Perl function - ['foo','yabba','dabba','doo']. Hard coding all the values works fine, or even hard coding a specific array element works. However, just providing the array (with the hope that it'd just iterate through each value) doesn't work. It's hard to tell exactly what it's feeding into functionToInvoke(), but it looks like it's trying to feed the index and then element. Any ideas? EDIT: Just a bit more information... I tried code:
syphon^2 fucked around with this message at 15:30 on Apr 22, 2008 |
|
# ¿ Apr 22, 2008 15:08 |
|
|
# ¿ Apr 27, 2024 07:03 |
Fehler posted:You might be looking for the concat() method. Try something like this: How come alert seemed to display my data properly, but when supplying it in the same manner for functionToInvoke, it failed? Maybe something to do with how CGI::Ajax works?
|
|
# ¿ Apr 22, 2008 15:34 |
EDIT: ^^^^^ Duly noted (right on the heels of another post). Thanks for the tip. Another javascript question... I'm trying to use setInterval() and setTimeout() to create a basic timer. I want my page to run doIt() every 10 seconds for 30 minutes, and then stop. (although I have the times cut down drastically for testing purposes) code:
Note that if I change code:
code:
This seems like a pretty simple use-case. What am I doing wrong?
|
|
# ¿ Apr 22, 2008 18:02 |
Fehler posted:Try making intervalID global, i.e. add "var intervalID;" at the top outside the function. Awesome... that seems to have done the trick! One last time... before I stop pestering you java gurus with js questions... why did this happen? I mean, obviously having intervalID as an argument within an argument brought it out of scope from where it was declared... but why would it do that? Also, how can I reference the intervalID scoped inside the autoDoIt() function? Given the layout of my .js file... I really really want to avoid having a single random global floating around there.
|
|
# ¿ Apr 22, 2008 20:19 |