Page 1 of 1

Reply from Login service question

Posted: Sat Mar 01, 2014 9:29 pm
by Bad Addy

I want to use the error messages received when there. But I not not sure how to get the information.

I am getting this message, which i want to get the code, to action something and print the description:

Image

This is the code I am using to get the messages

precode
error: function(etext) {
$('#loginLabel').text('Error:' + etext.code);
}
/code/pre

I am getting 'undefined'! I also tried etext['code']

Thank you


Reply from Login service question

Posted: Sat Mar 01, 2014 10:28 pm
by maxkatz

Where and how did you define the function? Here is how to handle errors from a service: http://docs.appery.io/documentation/r...


Reply from Login service question

Posted: Sun Mar 02, 2014 9:13 am
by Bad Addy

Yeah, sorry Max, but that really is no help.

textStatus only gives me 'error', errorThrown only gives me 'not found'. Where as still, like my post above, the response from the server is:

code : DBUI110
description: User does not exist

It is those I want to get hold of!


Reply from Login service question

Posted: Mon Mar 03, 2014 6:11 am
by Igor

For direct access to the error response object you have to:

1 Bind Javascript event handler to the "Error" event for login service;
2 Fill this event handler by following code:

pre
code
var responseText = jqXHR.responseText;
var response = JSON.parse(responseText);
console.log("error code = " + response.code);
console.log("error description = " + response.description);
/code
/pre