I am trying to authenticate my user using a POST request. But when I call to the rest call through jQuery it goes to the error state and returns error code 0.
When I call to the same rest call using postman or rest client, it gives me output as expected.
My jQuery is below,
$(document).ready(function() {
alert('started');
var dataType="application/json";
var data = {userName:"admin",password:"admin"};
$.ajax({
    type: "POST",
    url: "https://appserver.dev.cloud.wso2.com/t/madusanka/webapps/projecttracker-default-SNAPSHOT/services/projecttracker/userservice/users/authenticate",
    data: data,
    async : false,
    success: function(){alert("success")},
    error: function(){alert("error")},
    complete: function(){alert("complete")},
    statusCode: { 
        0: function() { alert( "0 : What happened here" )},
        404: function() { alert( "404 : Page not found" )},
        500: function() { alert( "500 : Internal server error" )}
    },
    dataType: dataType
}).then(function(data) {
   //handle the user here
});
});
I don't know why this returns http error 0. I called to https://appserver.dev.cloud.wso2.com/t/madusanka/webapps/projecttracker-default-SNAPSHOT/services/projecttracker/userservice/users/authenticate with userName=admin&password=admin and got the following output.
{
    Users: {
      User: {
        userName: "admin"
        userRoleId: 13268
      }
    }
}
Any ideas on this? Thanks in advance.!!
 
     
    