Hi,

I am trying to use ajax in my webpage.

I got the values from the database and displayed as links as below.

param1
param2
param3

I used the following code to call a javascript function func() with dynamic parameter param in jsp.


out.println("<a href='#' onclick='javascript:func('"+ param +"')'>"+ param +"</a>

where param is the dynamic variable that recieved from database.

My problem is If i click the link above mentioned, the javascript function didn't called.

I want to know What is the problem clearly??

Thanks in advance,

yuvi

Use Firefox when developing and look at the error console which shows all the Javascript errors on your page. Also, look at the source code generated for the above lines and see if there are any quote escaping issues which are pretty normal when spitting HTML using Servlets. It is recommend to switch to JSP for rendering (your view i.e. HTML) and use Servlets to handle things like form submission, file uploads etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.