Page 2 of 2
How to handle jqXHR object
Posted: Fri Aug 02, 2013 11:22 pm
by Pasteur Miranda
When I invoke the service and go to the "Preview" tab in network, I do receive the "DENIED;" response as you received. But I receive, also, the ERROR alert indicating that the ERROR event of the datasource was raised. Could You try to put an ERROR event in the datasource and tell me if it's raised too?
How to handle jqXHR object
Posted: Fri Aug 02, 2013 11:48 pm
by maxkatz
I think the error handler is called because no valid JSON is returned. Can you try returning a JSON response?
How to handle jqXHR object
Posted: Sat Aug 03, 2013 12:01 am
by Pasteur Miranda
Hi Max,
Code: Select all
Yes, I can try. But according to "Building 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] ) I understood that it's possible to handle "not Json" or "not XML" responses (see item "Exchange the code for a user access token" ).
Thank you
How to handle jqXHR object
Posted: Sat Aug 03, 2013 12:07 am
by maxkatz
The 'complete' callback is used there.. it will always be called after either success/error. I'm guessing error callback is also invoked there.. just nothing happens there.
How to handle jqXHR object
Posted: Sat Aug 03, 2013 12:25 am
by Pasteur Miranda
Hi Max,
Code: Select all
Your last comment was very helpful. It worked! Despite the ERROR event is raised, I handled the COMPLETE event and got the returned text using the following code:
var vars = jqXHR.responseText.split("&");
alert(vars[0]);
As a suggestion, I think you could add "text" option to the Data Type property of the service definition so that the ERROR event is not raised.
Thank you very much for your amazing application builder and also amazing support!
How to handle jqXHR object
Posted: Sat Aug 03, 2013 9:27 pm
by maxkatz
I will check whether an error should be thrown if no JSON is returned.