Page 2 of 3

Manipulate REST output before JSON parsing

Posted: Sun Jan 06, 2013 7:04 pm
by Renjith V

I got why the try/catch is not effective. Try is only for invoking the service. The response happens elsewhere in a different thread context.


Manipulate REST output before JSON parsing

Posted: Sun Jan 06, 2013 7:04 pm
by maxkatz

Delete and then re-create the service. Run it without any custom code, then add your code.


Manipulate REST output before JSON parsing

Posted: Sun Jan 06, 2013 7:04 pm
by Renjith V

Ok, let it fail. What eventually happens is that the animation that comes in front of the screen (with the rotating icon) never goes. Is there a way to at least get rid of that?


Manipulate REST output before JSON parsing

Posted: Sun Jan 06, 2013 7:05 pm
by Renjith V

You mean only in the data page or even the Service itself from the application?


Manipulate REST output before JSON parsing

Posted: Sun Jan 06, 2013 7:09 pm
by maxkatz

Service instance and the service.


Manipulate REST output before JSON parsing

Posted: Sun Jan 06, 2013 7:34 pm
by Renjith V

Ok, I didn't have succes with anything, now I am calling hideSpinner(); so that the screen is not blocked. A temporary relief.


Manipulate REST output before JSON parsing

Posted: Sun Jan 06, 2013 11:17 pm
by Emmz

Because you can never really trust server response. I always use try/catch before sending response to JSON.parse.
The error your showing is due to failed parse of what was sent to it.


Manipulate REST output before JSON parsing

Posted: Sun Jan 06, 2013 11:21 pm
by Emmz

See whats really comming back first by using the browsers debugging . Maybe add this.
codevar responseTxt =(jqXHR.responseText);/code
This will show content. Arrays within Object etc.


Manipulate REST output before JSON parsing

Posted: Sat Jan 12, 2013 8:05 am
by Renjith V

Btw, I still have not figured out a clean way for this. I tried all the suggestions. I am sure this happens if we create a sample JSON that returns an invalid response. None of the callbacks are called. Possible for anyone to try? I am still on the free plan and hence can create only one project.
Still living with the hideSpinner so that the UI is not blocked. But that is not a clean solution as the loading is actually not complete when I hide it.


Manipulate REST output before JSON parsing

Posted: Sat Jan 12, 2013 7:28 pm
by maxkatz

Use Chrome Dev. Tools to see if the service is invoked and what it returns.