LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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.
 
Old 02-23-2021, 11:15 PM   #3
sanidhya077
LQ Newbie
 
Registered: Feb 2021
Posts: 1

Rep: Reputation: Disabled
thank you so much

lmao i had the same thing...tysm i tried that fix and its working now
 
  


Reply

Tags
times



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
USB Driver Probe function not being called xtom Fedora 1 11-10-2018 12:05 PM
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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:18 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration