<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/4.6.4">
</HEAD>
<BODY>
On Thu, 2013-06-06 at 10:44 -0500, Kris Borchers wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
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 [].
</PRE>
</BLOCKQUOTE>
<BR>
Thanks. I thought that the message body could be empty for the responses of DELETE requests. However as of jQ 1.9 empty responses are rejected. <BR>
<BR>
<BLOCKQUOTE TYPE=CITE>
<PRE>
On Jun 6, 2013, at 10:32 AM, Apostolos Emmanouilidis <<A HREF="mailto:aemmanou@redhat.com">aemmanou@redhat.com</A>> wrote:
<FONT COLOR="#737373">> Hi guys,</FONT>
<FONT COLOR="#737373">> </FONT>
<FONT COLOR="#737373">> While writing some tests for the AeroGear JS API, I came across the following issue:</FONT>
<FONT COLOR="#737373">> </FONT>
<FONT COLOR="#737373">> 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.</FONT>
<FONT COLOR="#737373">> </FONT>
<FONT COLOR="#737373">> 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:</FONT>
<FONT COLOR="#737373">> </FONT>
<FONT COLOR="#737373">> parseJSON: function( data ) {</FONT>
<FONT COLOR="#737373">> </FONT>
<FONT COLOR="#737373">> if (!data) {</FONT>
<FONT COLOR="#737373">> return null;</FONT>
<FONT COLOR="#737373">> }</FONT>
<FONT COLOR="#737373">> </FONT>
<FONT COLOR="#737373">> 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.</FONT>
<FONT COLOR="#737373">> </FONT>
<FONT COLOR="#737373">> Thanks,</FONT>
<FONT COLOR="#737373">> Tolis</FONT>
<FONT COLOR="#737373">> _______________________________________________</FONT>
<FONT COLOR="#737373">> aerogear-dev mailing list</FONT>
<FONT COLOR="#737373">> <A HREF="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</A></FONT>
<FONT COLOR="#737373">> <A HREF="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</A></FONT>
_______________________________________________
aerogear-dev mailing list
<A HREF="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</A>
<A HREF="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</A>
</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>