• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Alert data returned by Ajax

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic