wood burning stoves*
The moose likes JSP and the fly likes Simple ajax question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Simple ajax question" Watch "Simple ajax question" New topic
Author

Simple ajax question

Stamin Adrian
Ranch Hand

Joined: Dec 21, 2012
Posts: 34

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

Joined: Jan 10, 2002
Posts: 61437
    
  67

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stamin Adrian
Ranch Hand

Joined: Dec 21, 2012
Posts: 34

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

Joined: Jan 10, 2002
Posts: 61437
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple ajax question