aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Alert data returned by Ajax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Alert data returned by Ajax" Watch "Alert data returned by Ajax" New topic
Author

Alert data returned by Ajax

S Rajagopal
Greenhorn

Joined: Jun 17, 2010
Posts: 9
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

Joined: Jan 10, 2002
Posts: 61766
    
  67

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.)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
echarish Kumar
Ranch Hand

Joined: Feb 02, 2010
Posts: 42
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

Joined: Jan 10, 2002
Posts: 61766
    
  67

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Alert data returned by Ajax