LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 01-15-2008, 08:24 AM   #1
mohtasham1983
Member
 
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


Hi,

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

Code:
onclick="vote(this)
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, 08:31 AM   #2
mohtasham1983
Member
 
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.
 
  


Reply

Tags
times


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 08:25 PM
segfault caused depending on how a function is called emge1 Programming 6 04-04-2007 03:48 PM
what is the kernel function called when a file is created viv_nan Linux - General 2 03-08-2007 06:09 AM
howto know whether a function is called in signal handler snowing Programming 1 11-07-2005 09:55 PM
USB Driver Probe function not being called xtom Fedora 0 10-28-2005 03:48 PM


All times are GMT -5. The time now is 05:23 AM.

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