• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alert data returned by Ajax

 
S Rajagopal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have button in my Jsp page which triggers an Ajax call.The Ajax call directs the call to contoller which performs the action and returns the result (i.e success or failure )to a jsp page .
The data from this jsp page gets inserted into the <div> tag of the orginal Jsp page.
Is it possible to use an alert to notify the data retuned by ajax call?
Thanks in advance.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64716
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
S Rajagopal wrote:I have button in my Jsp page which triggers an Ajax call.

Clarification: no you don't. You have a button in your HTML page. JSP only exists on the server. Once the response is sent to the browser, it's just an HTML page like any other.

Is it possible to use an alert to notify the data retuned by ajax call?

You can do whatever you want in the callback, including issuing an alert. (But why? Alerts are awful.)
 
echarish Kumar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do whatever you want after you get the response here is a sample to show you

This is the code for JS

and this is what you should do in your ajax action
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64716
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
echarish Kumar wrote:
This is the code for JS

You did not mention that this assumes the use of jQuery, which is recommended for doing things like Ajax.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic