Hi,
Code: Select all
I'm trying to retrieve the response from a REST service, but I'm not going to define a response. Instead, I would like to read the response direct and retrieve this response. I'm using as an example, the "Build an App with Facebook API" tutorial ([url=http://docs.appery.io/tutorials/build-an-app-with-facebook-api/]http://docs.appery.io/tutorials/build...[/url] ).
So I defined a service named RESTService (URL [url=http://www12.itrack.com.br/itrackmon/rest/login/{usuario}/{senha}]http://www12.itrack.com.br/itrackmon/...[/url] ) which has the request parameters "usuario" and "senha" . I tested this service in the "test" page and it is working. The service return one of these strings (it returns plain text, not json or xml):
DENIED; (returned if "usuario" and "senha" are wrong)
SUCCESSFUL;1ce3e47aa7a94e8ba4091b74c6aa6275 (returned if "usuario" and "senha" are right ).
Following the tutorial, I defined one datasource named loginservice, and mapped the parameters "usario" and "senha" to 2 input boxes. After, I created an event (Complete) to the loginservice datasource and added a "Run Javascript" action to it. The javascript code associated to the action is :
var vars = jqXHR.responseText.split(";");
alert (vars[0]);
Finally I defined a click event to a button and associated to this event an action "Invoke Service" that invokes the loginservice datasource.
When I run the application, fill "usario" and "senha" inputs, and invoke the service clicking the button, the alert window comes empty (it had to show DENIED or SUCCESSFUL)!
What am I doing wrong? Is there any problem in the way I'm using the jqXHR object?
Thank you very much in advance