[aerogear-dev] AeroGear Android & JS API remove operation
Kris Borchers
kris at redhat.com
Thu Jun 6 11:44:19 EDT 2013
So the issue here is the backend service. If the DELETE request is sent and an application/json response is expected, the backend must send valid JSON. An empty response is not valid JSON so jQuery gets it right by throwing an error. This was a recent addition/bug fix in jQuery to throw this error since that is the correct way to handle invalid JSON. The backend service needs to send something like [].
On Jun 6, 2013, at 10:32 AM, Apostolos Emmanouilidis <aemmanou at redhat.com> wrote:
> Hi guys,
>
> While writing some tests for the AeroGear JS API, I came across the following issue:
>
> The Pipe.remove method of the AeroGear Android API does not require any data as a response. The callback has Void data. This means that the corresponding operation on the server/backend side returns an empty response.
>
> However the AeroGear JS API relies on jQuery AJAX mechanism. When using the Pipe.remove method, jQuery tries to parse the empty response as JSON and it fails. I had to hack jQuery and add the following piece of code in order to use the same backend service for both AeroGear APIs:
>
> parseJSON: function( data ) {
>
> if (!data) {
> return null;
> }
>
> If you know any way to make the AeroGear JS Pipe.remove method to work when the server side returns an empty response and without hacking the JQuery, please share it.
>
> Thanks,
> Tolis
> _______________________________________________
> aerogear-dev mailing list
> aerogear-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/aerogear-dev
More information about the aerogear-dev
mailing list