Phazz
asked on
How to call a AJAX javascript funtion when clicking a link on a CGI generated HTML page?
My CGI application generates HTML code with links to some (precomputed) data on the server. The data is not used for anything unless the user clicks the link. Now I want to optimize the application using AJAX to generate the data on the fly only when the user clicks the link.
The following code would work in a normal HTML page:
<a href="#" onclick="AjaxFunction();re turn false;">link</a>
But it doesn't work in my case, I guess because the HTML page with the links was generated by the CGI. The browser looks for litterally "#" at the root of my website (www.example.com/#)
The following code would work in a normal HTML page:
<a href="#" onclick="AjaxFunction();re
But it doesn't work in my case, I guess because the HTML page with the links was generated by the CGI. The browser looks for litterally "#" at the root of my website (www.example.com/#)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to both of you!
Guruvinder372's first suggestion doesn't work, but the second one works perfectly. Djuzoran's suggestion works too.
Actually I found out that my original code in the question also works! - but my AjaxFunction wasn't executed (misspelled function name, embarrassing, huh?)
Is any of the suggestions best in terms of cross-browser support?
Guruvinder372's first suggestion doesn't work, but the second one works perfectly. Djuzoran's suggestion works too.
Actually I found out that my original code in the question also works! - but my AjaxFunction wasn't executed (misspelled function name, embarrassing, huh?)
Is any of the suggestions best in terms of cross-browser support?
both should works on all browsers.
ASKER
Thanks for your help.
thanks for the points
Does the AjaxFunction() method gets called?