Lisa Anne
Lisa Anne

Reputation: 4595

Why do I get error in Sencha HTTP post?

I am totally novice to Sencha, please forgive me for the naive question.

If I try to do the following HTTP Post to the following address https://api.pericoach.xyzhee.com

WS.authenticateUser = function (accountName, pwd, successCallback, errorCallback)
{
console.log('** WS.authenticateUser() **');
console.log('** WS.authenticateUser() >> WS.serverUrl: ' + WS.serverUrl);


$.ajax({
    url: WS.serverUrl + "/Mobile/Login",
    type: "POST",
    data: { username: accountName, password: pwd },
    async : true,
    dataType: 'json',
    statusCode:
    {
        403: function (data) {
            console.log('** WS.authenticateUser -- 403 **');

            //alert("403: " + data.Message);
            callback(data);
        }
    },
    success: function (data, textStatus, jqXHR) 
    {
        console.log('** WS.authenticateUser -- success **');

        //alert("success: " + data.Message + " - " + data.Token + " - " + data.TokenDate);
        successCallback(data);
    },
    error: function (jqXHR, textStatus, errorThrown)
    {
        console.log('** WS.authenticateUser -- error **');

        errorCallback();
    }
});
};

Were

user = patient

password = password123

But the always the error callback gets called !!

The errorThrown = SyntaxError: Unexpected end of input

If I try with something like Postman I get the following:

{
"Message": null,
"Token": "40684f9d-ebab-433c-acaf-fddf5204a3b9",
"TokenDate": "21/07/2014 12:00:00 AM",
"Username": "Patient",
"FirstName": "Patient",
"LastName": "Name",
"PatientID": "26cb7141-a624-4fd1-adfd-06a8ebf2025c",
"PatientSFID": null,
"ClinicianID": "00000000-0000-0000-0000-000000000000",
"UserType": 1,
"Success": true,
"SubscriptionExpired": false
}

Upvotes: 0

Views: 50

Answers (1)

Lisa Anne
Lisa Anne

Reputation: 4595

In case it might be useful for other people:

Domain whitelisting (see PhoneGap docs)

<access origin="*" />

This solved the issue!

Upvotes: 2

Related Questions