• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending response to ajax from Java  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Team,

I have a snippet of code like below,



From the above code i want to pass the value comtval as  a parameter to the function  saveEditComment(),and then send this whole html table as response to ajax response,i am getting the response but i could not get the comtval value ,it is also just appended as a string value.
Please find the response from ajax side




can anyone please help me out on how to pass the argument value also.

Thanks in Advance.
D.Srikanth
 
Rancher
Posts: 3538
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This probably ought to be in the Servlets section.

As for the problem itself, I can't tell where you expect the comtval to go.

Just to be clear on one thing, though.  Do you have to do the HTML inside the servlet?  Can you not use JSPs to produce this fragment?
Or even simply return all the data as JSON and let the front end sort it out?
 
Sheriff
Posts: 23594
48
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:As for the problem itself, I can't tell where you expect the comtval to go.



My guess is that the "function" it's supposed to go to is a JavaScript function. Which is a problematic design, since this code is running on the server and knows nothing about JavaScript in the browser. And then, apparently, the resulting HTML is supposed to be returned to the browser, to be handled by some AJAX code.

If that's the case then this design isn't going to work. You'll have to return the comtval data as part of the HTML and then have the AJAX code call that function. Just as Dave suggested, in fact.
 
Evil is afoot. But this tiny ad is just an ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!