Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-15-2008, 09:24 AM   #1
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Rep: Reputation: 30
Thumbs up JavaScript function disappears after getting called for once


I have 15 html anchor elements in my page with the following handler:

Each of the anchor elements are used for rating the corresponding news. So I passed "this" to the vote function so that it rates the proper news. The vote function uses YUI library to send an asynchronous request to the server and get the result of the page without reloading it (AJAX). So far everything is fine, but after calling vote function once, when I call it using another anchor element, firebug gives me an error that vote is not a function. I don't know why I cannot access it after calling it for once.

If I reload the page, I can call vote function again for once. But I don't want to reload the entire page for every simple request I send to the server and that's why I am interested in using AJAX.

I'm not very familiar with JavaScript tricks, I bet there is a trick to handle this situation.

Thanks in advance.
Old 01-15-2008, 09:31 AM   #2
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
It was kinda funny, but after renaming the vote function to vote_news, I got everything working. I think there was another element in the page called "vote" which prevented the vote function to be called.

I hope this post can help somebody.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
sleeping function called from invalid context kushneeraj Programming 8 04-16-2013 09:25 PM
segfault caused depending on how a function is called emge1 Programming 6 04-04-2007 04:48 PM
what is the kernel function called when a file is created viv_nan Linux - General 2 03-08-2007 07:09 AM
howto know whether a function is called in signal handler snowing Programming 1 11-07-2005 10:55 PM
USB Driver Probe function not being called xtom Fedora 0 10-28-2005 04:48 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:57 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration