0

I have a JavaScript file that calls a method of the Grails controller by ajax , but I have to create the Login.gsp. I do not want to create this view.

Ext.Ajax.request({
 url: 'user/login', 
 params: {
   user: user,
   password: pass
 }
});

The method is called, but in Chrome console have the output:

POST localhost:8080/myapp/user/login 404 (Not Found)

1 Answer 1

2

You dont have to create a view for it. Add a "login" method in your UserController and return a JSON result

class UserController{

  def login(){
    //Your code...
    render result as JSON
  }
}

If you are using SpringSecurity make sure that the login method is accesible for non-authenticated users.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @agusluc, i resolved, I tried using the render(status: 200, text: "ok") and it worked : D
Glad to hear. My suggestion of rendering json content instead of a request with plain text is for take advantage of the grails validation messages and the i18n support while using AJAX

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.