• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple ajax question

 
Stamin Adrian
Ranch Hand
Posts: 34
Chrome Netbeans IDE Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to learn how to tell the succes and error events in ajax to show messages according to a java value.
My boolean value will tell me if the user is ok to login or not.This is my server side loginForm.jsp


This is my javascript function


Any help would be apreciated.I really need to understand how succes and error work and the most secure way to do such login actions.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64181
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really can't tell what you are trying to accomplish, but there should not be any Java scriptlets in modern JSP pages.

In any case, Ajax cannot interact with any Java that you do put in the JSP. What are you actually trying to accomplish?
 
Stamin Adrian
Ranch Hand
Posts: 34
Chrome Netbeans IDE Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does succes and error work? I want to show a message only when the boolean is true or false.It seems succes is called whenever the data gets there corectly.But I want more than that.I want to show a succes message when I am 100% positive that the server-side code worked.Is succes and error reliable?What if the data gets on my jsp page, but it fails to make the controller call corectly.It will still point out to the user that the action was succesfull.I know modern jsp pages don't have scriptlets on.In the future I will try it that way.I only use managed beans on the pages.I have different beans for the view.It's still MVC.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64181
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error or success of the request is available as the status code of the response. The server-side operation needs to set the status code correctly.

You don't need Java at all for any of this. All Ajax-y stuff can happen using JavaScript.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic