Ajax function does not pass through success

7

My role calling my web service

  var email = document.getElementById("email").value  
     var senha = document.getElementById("senha").value 

      $.ajax({
        url: "http://localhost:8080/Servidor/rest/service/loginCustmerUser/"+ email + ","+ senha,
        dataType: "json",
        type: "GET",
        async: false,
        success: function (data) {
           alert(data)
        }, 
        error: function(e){
            alert("Erro: " + e);

        }, 

    }); 

My method in webservice

@GET
@Produces("application/json")
@Path("/loginCustmerUser/{email},{senha}")
public String loginClientUser(@PathParam("email") String email,
        @PathParam("senha") String senha) {
    NotaFiscalBO bo = new NotaFiscalBO();
    CustmerUser cUser = bo.loginCustmerUser(email);


    try {
        boolean validacao = validarCustmerUserLogin(senha,
                cUser.getPassword());
        if (!validacao) {
            cUser = null;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return new Gson().toJson(cUser);
}

Method Return

{"id": 3, "login": "test", "password": "2482e34cc83b09ba9088b2af8bf11866"}

    
asked by anonymous 08.09.2015 / 23:53

1 answer

1

Apparently there is nothing wrong with your code, try running the URL in a browser and verify that the user will be logged in. Usually I do this:

@GET
@Path("/loginCustmerUser")
@Consumes(MediaType.APPLICATION_JSON + ";charset=utf-8")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public Response logar(@QueryParam("email") String email,
        @QueryParam("senha") String senha) {

        LoginService loginService = new LoginService();
        Usuario usuario= loginService.logar(email, senha);
        return Response.status(Response.Status.ACCEPTED).entity(usuario).build();

}   

My URL would look like this: link

I hope I have helped.

    
09.09.2015 / 02:45