You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Simon Chen <si...@gmail.com> on 2011/05/13 23:14:21 UTC
server got OPTIONS instead of DELETE
Hi all,
I am trying to write a piece of javascript in an HTML page that will
do a DELETE to a URL in a REST web service. However, my web service
only gets OPTIONS requests for some reason.
The html looks like this:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<form id="searchForm">
<input type="text" name="s" />
<input type="submit" value="Search" />
</form>
<div id="result"></div>
<script>
$("#searchForm").submit(function(event) {
event.preventDefault();
$.ajax({
url: 'http://localhost:9000/test',
type: 'DELETE',
success: function(data) {
alert('succeed');
}
});
});
</script>
</body>
</html>
However, I got this for my webservice:
INFO: Inbound Message
----------------------------
ID: 53
Address: /test
Http-Method: OPTIONS <------SOMETHING WRONG HERE, in chrome>
Content-Type:
Headers: {Accept-Language=[en-US,en;q=0.8],
Access-Control-Request-Headers=[Accept], connection=[keep-alive],
Host=[localhost:9000],
Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.3],
User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24
(KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.24],
accept-encoding=[gzip,deflate,sdch], Origin=[null],
Access-Control-Request-Method=[DELETE], Content-Type=[null],
Accept=[*/*]}
-------------------------------------
ID: 54
Address: /test
Http-Method: OPTIONS <------SOMETHING WRONG HERE, in firefox too>
Content-Type:
Headers: {Accept-Language=[en-us,en;q=0.5], connection=[keep-alive],
Host=[localhost:9000],
Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], Keep-Alive=[115],
User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1)
Gecko/20100101 Firefox/4.0.1], Origin=[null], accept-encoding=[gzip,
deflate], Access-Control-Request-Method=[DELETE], Content-Type=[null],
Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]}
Since the method is somehow OPTIONS, of coz, my webservice will
complain "no cause is available". In the header, it shows
"Access-Control-Request-Method=[DELETE]", but I don't know what it
means. IE doesn't even bother to send out a request...
Any ideas?
-Simon
Re: server got OPTIONS instead of DELETE
Posted by Simon Chen <si...@gmail.com>.
Emmm... I am making myself laughable again :-(
It turns out that those browsers are acting correctly. The policy they
have is that if the POST/DELETE/PUT are to a different domain, the
requests are turned into OPTIONS automatically for good reasons. I was
making a test page on my file system (who wouldn't?), while trying to
post something to the web service I build - of coz they're under
different domains!
When I perform POST/DELETE/PUT from a page on my webservice, it works
fine (only tested chrome though...)
-Simon
On Sun, May 15, 2011 at 2:26 PM, Simon Chen <si...@gmail.com> wrote:
> It seems that the browsers do have a bunch of limitations in terms of
> the operations allowed. For example, a lot of browsers don't allow
> POST to a different domain than the web server.
>
> Chrome even sends my POSTs as OPTIONS, while FireFox is brave enough
> to send out an actual POST.
>
> Maybe it's just browsers screwing up, or maybe my webservice, no idea :-(
>
> -Simon
>
> On Sun, May 15, 2011 at 12:54 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
>> Hi
>>
>> Perhaps 'DELETE' can not be called explicitly from the browser script
>> ? I've no other ideas.
>> One thing to try is to express the method that needs to be called
>> using a _method query key, example
>>
>> ?_method=DELETE
>> ?_method=PUT
>>
>> and just let browser do GET and POST only, provided it can't say do
>> PUT or DELETE from the embedded script
>>
>> Cheers, Sergey
>>
>>
>> On Fri, May 13, 2011 at 10:41 PM, Simon Chen <si...@gmail.com> wrote:
>>> Another question. (Sorry for the excessive messages...)
>>>
>>> If you notice, the ajax call have a call back function
>>> $.ajax({
>>> url: 'http://localhost:9000/slices/claude',
>>> type: 'DELETE',
>>> success: function(data) {
>>> alert('succeed' + data);
>>> }
>>> });
>>>
>>> The puzzling thing is that the callback function was never called,
>>> although my faked DELETE handler returns success, like this:
>>> ID: 1
>>> Response-Code: 200
>>> Content-Type: text/xml
>>> Headers: {Date=[Fri, 13 May 2011 21:38:54 GMT]}
>>> Payload: delete ok
>>>
>>>
>>> Any ideas?
>>>
>>> Thanks.
>>> -Simon
>>>
>>>
>>> On Fri, May 13, 2011 at 5:24 PM, Simon Chen <si...@gmail.com> wrote:
>>>> I kinda solved the problem with a tweak, essentially I have:
>>>>
>>>> @OPTIONS
>>>> @Path("/test/{name}")
>>>> public Response deleteByOptions(@PathParam("name")
>>>> java.lang.String name, @HeaderParam("Access-Control-Request-Method")
>>>> String method) {
>>>>
>>>> Response r = Response.notModified().build();
>>>> if (method == null || ! method.equals("DELETE")) {
>>>> return r;
>>>> }
>>>> ...
>>>> return r;
>>>> }
>>>>
>>>> But I still wonder what the correct way is...
>>>>
>>>> Thanks.
>>>> -Simon
>>>>
>>>>
>>>> On Fri, May 13, 2011 at 5:14 PM, Simon Chen <si...@gmail.com> wrote:
>>>>> Hi all,
>>>>>
>>>>> I am trying to write a piece of javascript in an HTML page that will
>>>>> do a DELETE to a URL in a REST web service. However, my web service
>>>>> only gets OPTIONS requests for some reason.
>>>>>
>>>>> The html looks like this:
>>>>>
>>>>> <!DOCTYPE html>
>>>>> <html>
>>>>> <head>
>>>>> <script src="http://code.jquery.com/jquery-latest.js"></script>
>>>>> </head>
>>>>> <body>
>>>>> <form id="searchForm">
>>>>> <input type="text" name="s" />
>>>>> <input type="submit" value="Search" />
>>>>> </form>
>>>>> <div id="result"></div>
>>>>> <script>
>>>>> $("#searchForm").submit(function(event) {
>>>>> event.preventDefault();
>>>>> $.ajax({
>>>>> url: 'http://localhost:9000/test',
>>>>> type: 'DELETE',
>>>>> success: function(data) {
>>>>> alert('succeed');
>>>>> }
>>>>> });
>>>>> });
>>>>> </script>
>>>>> </body>
>>>>> </html>
>>>>>
>>>>>
>>>>> However, I got this for my webservice:
>>>>> INFO: Inbound Message
>>>>> ----------------------------
>>>>> ID: 53
>>>>> Address: /test
>>>>> Http-Method: OPTIONS <------SOMETHING WRONG HERE, in chrome>
>>>>> Content-Type:
>>>>> Headers: {Accept-Language=[en-US,en;q=0.8],
>>>>> Access-Control-Request-Headers=[Accept], connection=[keep-alive],
>>>>> Host=[localhost:9000],
>>>>> Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.3],
>>>>> User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24
>>>>> (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.24],
>>>>> accept-encoding=[gzip,deflate,sdch], Origin=[null],
>>>>> Access-Control-Request-Method=[DELETE], Content-Type=[null],
>>>>> Accept=[*/*]}
>>>>> -------------------------------------
>>>>>
>>>>> ID: 54
>>>>> Address: /test
>>>>> Http-Method: OPTIONS <------SOMETHING WRONG HERE, in firefox too>
>>>>> Content-Type:
>>>>> Headers: {Accept-Language=[en-us,en;q=0.5], connection=[keep-alive],
>>>>> Host=[localhost:9000],
>>>>> Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], Keep-Alive=[115],
>>>>> User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1)
>>>>> Gecko/20100101 Firefox/4.0.1], Origin=[null], accept-encoding=[gzip,
>>>>> deflate], Access-Control-Request-Method=[DELETE], Content-Type=[null],
>>>>> Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]}
>>>>>
>>>>> Since the method is somehow OPTIONS, of coz, my webservice will
>>>>> complain "no cause is available". In the header, it shows
>>>>> "Access-Control-Request-Method=[DELETE]", but I don't know what it
>>>>> means. IE doesn't even bother to send out a request...
>>>>>
>>>>>
>>>>>
>>>>> Any ideas?
>>>>>
>>>>> -Simon
>>>>>
>>>>
>>>
>>
>
Re: server got OPTIONS instead of DELETE
Posted by Simon Chen <si...@gmail.com>.
It seems that the browsers do have a bunch of limitations in terms of
the operations allowed. For example, a lot of browsers don't allow
POST to a different domain than the web server.
Chrome even sends my POSTs as OPTIONS, while FireFox is brave enough
to send out an actual POST.
Maybe it's just browsers screwing up, or maybe my webservice, no idea :-(
-Simon
On Sun, May 15, 2011 at 12:54 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
> Hi
>
> Perhaps 'DELETE' can not be called explicitly from the browser script
> ? I've no other ideas.
> One thing to try is to express the method that needs to be called
> using a _method query key, example
>
> ?_method=DELETE
> ?_method=PUT
>
> and just let browser do GET and POST only, provided it can't say do
> PUT or DELETE from the embedded script
>
> Cheers, Sergey
>
>
> On Fri, May 13, 2011 at 10:41 PM, Simon Chen <si...@gmail.com> wrote:
>> Another question. (Sorry for the excessive messages...)
>>
>> If you notice, the ajax call have a call back function
>> $.ajax({
>> url: 'http://localhost:9000/slices/claude',
>> type: 'DELETE',
>> success: function(data) {
>> alert('succeed' + data);
>> }
>> });
>>
>> The puzzling thing is that the callback function was never called,
>> although my faked DELETE handler returns success, like this:
>> ID: 1
>> Response-Code: 200
>> Content-Type: text/xml
>> Headers: {Date=[Fri, 13 May 2011 21:38:54 GMT]}
>> Payload: delete ok
>>
>>
>> Any ideas?
>>
>> Thanks.
>> -Simon
>>
>>
>> On Fri, May 13, 2011 at 5:24 PM, Simon Chen <si...@gmail.com> wrote:
>>> I kinda solved the problem with a tweak, essentially I have:
>>>
>>> @OPTIONS
>>> @Path("/test/{name}")
>>> public Response deleteByOptions(@PathParam("name")
>>> java.lang.String name, @HeaderParam("Access-Control-Request-Method")
>>> String method) {
>>>
>>> Response r = Response.notModified().build();
>>> if (method == null || ! method.equals("DELETE")) {
>>> return r;
>>> }
>>> ...
>>> return r;
>>> }
>>>
>>> But I still wonder what the correct way is...
>>>
>>> Thanks.
>>> -Simon
>>>
>>>
>>> On Fri, May 13, 2011 at 5:14 PM, Simon Chen <si...@gmail.com> wrote:
>>>> Hi all,
>>>>
>>>> I am trying to write a piece of javascript in an HTML page that will
>>>> do a DELETE to a URL in a REST web service. However, my web service
>>>> only gets OPTIONS requests for some reason.
>>>>
>>>> The html looks like this:
>>>>
>>>> <!DOCTYPE html>
>>>> <html>
>>>> <head>
>>>> <script src="http://code.jquery.com/jquery-latest.js"></script>
>>>> </head>
>>>> <body>
>>>> <form id="searchForm">
>>>> <input type="text" name="s" />
>>>> <input type="submit" value="Search" />
>>>> </form>
>>>> <div id="result"></div>
>>>> <script>
>>>> $("#searchForm").submit(function(event) {
>>>> event.preventDefault();
>>>> $.ajax({
>>>> url: 'http://localhost:9000/test',
>>>> type: 'DELETE',
>>>> success: function(data) {
>>>> alert('succeed');
>>>> }
>>>> });
>>>> });
>>>> </script>
>>>> </body>
>>>> </html>
>>>>
>>>>
>>>> However, I got this for my webservice:
>>>> INFO: Inbound Message
>>>> ----------------------------
>>>> ID: 53
>>>> Address: /test
>>>> Http-Method: OPTIONS <------SOMETHING WRONG HERE, in chrome>
>>>> Content-Type:
>>>> Headers: {Accept-Language=[en-US,en;q=0.8],
>>>> Access-Control-Request-Headers=[Accept], connection=[keep-alive],
>>>> Host=[localhost:9000],
>>>> Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.3],
>>>> User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24
>>>> (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.24],
>>>> accept-encoding=[gzip,deflate,sdch], Origin=[null],
>>>> Access-Control-Request-Method=[DELETE], Content-Type=[null],
>>>> Accept=[*/*]}
>>>> -------------------------------------
>>>>
>>>> ID: 54
>>>> Address: /test
>>>> Http-Method: OPTIONS <------SOMETHING WRONG HERE, in firefox too>
>>>> Content-Type:
>>>> Headers: {Accept-Language=[en-us,en;q=0.5], connection=[keep-alive],
>>>> Host=[localhost:9000],
>>>> Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], Keep-Alive=[115],
>>>> User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1)
>>>> Gecko/20100101 Firefox/4.0.1], Origin=[null], accept-encoding=[gzip,
>>>> deflate], Access-Control-Request-Method=[DELETE], Content-Type=[null],
>>>> Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]}
>>>>
>>>> Since the method is somehow OPTIONS, of coz, my webservice will
>>>> complain "no cause is available". In the header, it shows
>>>> "Access-Control-Request-Method=[DELETE]", but I don't know what it
>>>> means. IE doesn't even bother to send out a request...
>>>>
>>>>
>>>>
>>>> Any ideas?
>>>>
>>>> -Simon
>>>>
>>>
>>
>
Re: server got OPTIONS instead of DELETE
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
Perhaps 'DELETE' can not be called explicitly from the browser script
? I've no other ideas.
One thing to try is to express the method that needs to be called
using a _method query key, example
?_method=DELETE
?_method=PUT
and just let browser do GET and POST only, provided it can't say do
PUT or DELETE from the embedded script
Cheers, Sergey
On Fri, May 13, 2011 at 10:41 PM, Simon Chen <si...@gmail.com> wrote:
> Another question. (Sorry for the excessive messages...)
>
> If you notice, the ajax call have a call back function
> $.ajax({
> url: 'http://localhost:9000/slices/claude',
> type: 'DELETE',
> success: function(data) {
> alert('succeed' + data);
> }
> });
>
> The puzzling thing is that the callback function was never called,
> although my faked DELETE handler returns success, like this:
> ID: 1
> Response-Code: 200
> Content-Type: text/xml
> Headers: {Date=[Fri, 13 May 2011 21:38:54 GMT]}
> Payload: delete ok
>
>
> Any ideas?
>
> Thanks.
> -Simon
>
>
> On Fri, May 13, 2011 at 5:24 PM, Simon Chen <si...@gmail.com> wrote:
>> I kinda solved the problem with a tweak, essentially I have:
>>
>> @OPTIONS
>> @Path("/test/{name}")
>> public Response deleteByOptions(@PathParam("name")
>> java.lang.String name, @HeaderParam("Access-Control-Request-Method")
>> String method) {
>>
>> Response r = Response.notModified().build();
>> if (method == null || ! method.equals("DELETE")) {
>> return r;
>> }
>> ...
>> return r;
>> }
>>
>> But I still wonder what the correct way is...
>>
>> Thanks.
>> -Simon
>>
>>
>> On Fri, May 13, 2011 at 5:14 PM, Simon Chen <si...@gmail.com> wrote:
>>> Hi all,
>>>
>>> I am trying to write a piece of javascript in an HTML page that will
>>> do a DELETE to a URL in a REST web service. However, my web service
>>> only gets OPTIONS requests for some reason.
>>>
>>> The html looks like this:
>>>
>>> <!DOCTYPE html>
>>> <html>
>>> <head>
>>> <script src="http://code.jquery.com/jquery-latest.js"></script>
>>> </head>
>>> <body>
>>> <form id="searchForm">
>>> <input type="text" name="s" />
>>> <input type="submit" value="Search" />
>>> </form>
>>> <div id="result"></div>
>>> <script>
>>> $("#searchForm").submit(function(event) {
>>> event.preventDefault();
>>> $.ajax({
>>> url: 'http://localhost:9000/test',
>>> type: 'DELETE',
>>> success: function(data) {
>>> alert('succeed');
>>> }
>>> });
>>> });
>>> </script>
>>> </body>
>>> </html>
>>>
>>>
>>> However, I got this for my webservice:
>>> INFO: Inbound Message
>>> ----------------------------
>>> ID: 53
>>> Address: /test
>>> Http-Method: OPTIONS <------SOMETHING WRONG HERE, in chrome>
>>> Content-Type:
>>> Headers: {Accept-Language=[en-US,en;q=0.8],
>>> Access-Control-Request-Headers=[Accept], connection=[keep-alive],
>>> Host=[localhost:9000],
>>> Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.3],
>>> User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24
>>> (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.24],
>>> accept-encoding=[gzip,deflate,sdch], Origin=[null],
>>> Access-Control-Request-Method=[DELETE], Content-Type=[null],
>>> Accept=[*/*]}
>>> -------------------------------------
>>>
>>> ID: 54
>>> Address: /test
>>> Http-Method: OPTIONS <------SOMETHING WRONG HERE, in firefox too>
>>> Content-Type:
>>> Headers: {Accept-Language=[en-us,en;q=0.5], connection=[keep-alive],
>>> Host=[localhost:9000],
>>> Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], Keep-Alive=[115],
>>> User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1)
>>> Gecko/20100101 Firefox/4.0.1], Origin=[null], accept-encoding=[gzip,
>>> deflate], Access-Control-Request-Method=[DELETE], Content-Type=[null],
>>> Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]}
>>>
>>> Since the method is somehow OPTIONS, of coz, my webservice will
>>> complain "no cause is available". In the header, it shows
>>> "Access-Control-Request-Method=[DELETE]", but I don't know what it
>>> means. IE doesn't even bother to send out a request...
>>>
>>>
>>>
>>> Any ideas?
>>>
>>> -Simon
>>>
>>
>
Re: server got OPTIONS instead of DELETE
Posted by Simon Chen <si...@gmail.com>.
Another question. (Sorry for the excessive messages...)
If you notice, the ajax call have a call back function
$.ajax({
url: 'http://localhost:9000/slices/claude',
type: 'DELETE',
success: function(data) {
alert('succeed' + data);
}
});
The puzzling thing is that the callback function was never called,
although my faked DELETE handler returns success, like this:
ID: 1
Response-Code: 200
Content-Type: text/xml
Headers: {Date=[Fri, 13 May 2011 21:38:54 GMT]}
Payload: delete ok
Any ideas?
Thanks.
-Simon
On Fri, May 13, 2011 at 5:24 PM, Simon Chen <si...@gmail.com> wrote:
> I kinda solved the problem with a tweak, essentially I have:
>
> @OPTIONS
> @Path("/test/{name}")
> public Response deleteByOptions(@PathParam("name")
> java.lang.String name, @HeaderParam("Access-Control-Request-Method")
> String method) {
>
> Response r = Response.notModified().build();
> if (method == null || ! method.equals("DELETE")) {
> return r;
> }
> ...
> return r;
> }
>
> But I still wonder what the correct way is...
>
> Thanks.
> -Simon
>
>
> On Fri, May 13, 2011 at 5:14 PM, Simon Chen <si...@gmail.com> wrote:
>> Hi all,
>>
>> I am trying to write a piece of javascript in an HTML page that will
>> do a DELETE to a URL in a REST web service. However, my web service
>> only gets OPTIONS requests for some reason.
>>
>> The html looks like this:
>>
>> <!DOCTYPE html>
>> <html>
>> <head>
>> <script src="http://code.jquery.com/jquery-latest.js"></script>
>> </head>
>> <body>
>> <form id="searchForm">
>> <input type="text" name="s" />
>> <input type="submit" value="Search" />
>> </form>
>> <div id="result"></div>
>> <script>
>> $("#searchForm").submit(function(event) {
>> event.preventDefault();
>> $.ajax({
>> url: 'http://localhost:9000/test',
>> type: 'DELETE',
>> success: function(data) {
>> alert('succeed');
>> }
>> });
>> });
>> </script>
>> </body>
>> </html>
>>
>>
>> However, I got this for my webservice:
>> INFO: Inbound Message
>> ----------------------------
>> ID: 53
>> Address: /test
>> Http-Method: OPTIONS <------SOMETHING WRONG HERE, in chrome>
>> Content-Type:
>> Headers: {Accept-Language=[en-US,en;q=0.8],
>> Access-Control-Request-Headers=[Accept], connection=[keep-alive],
>> Host=[localhost:9000],
>> Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.3],
>> User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24
>> (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.24],
>> accept-encoding=[gzip,deflate,sdch], Origin=[null],
>> Access-Control-Request-Method=[DELETE], Content-Type=[null],
>> Accept=[*/*]}
>> -------------------------------------
>>
>> ID: 54
>> Address: /test
>> Http-Method: OPTIONS <------SOMETHING WRONG HERE, in firefox too>
>> Content-Type:
>> Headers: {Accept-Language=[en-us,en;q=0.5], connection=[keep-alive],
>> Host=[localhost:9000],
>> Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], Keep-Alive=[115],
>> User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1)
>> Gecko/20100101 Firefox/4.0.1], Origin=[null], accept-encoding=[gzip,
>> deflate], Access-Control-Request-Method=[DELETE], Content-Type=[null],
>> Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]}
>>
>> Since the method is somehow OPTIONS, of coz, my webservice will
>> complain "no cause is available". In the header, it shows
>> "Access-Control-Request-Method=[DELETE]", but I don't know what it
>> means. IE doesn't even bother to send out a request...
>>
>>
>>
>> Any ideas?
>>
>> -Simon
>>
>
Re: server got OPTIONS instead of DELETE
Posted by Simon Chen <si...@gmail.com>.
I kinda solved the problem with a tweak, essentially I have:
@OPTIONS
@Path("/test/{name}")
public Response deleteByOptions(@PathParam("name")
java.lang.String name, @HeaderParam("Access-Control-Request-Method")
String method) {
Response r = Response.notModified().build();
if (method == null || ! method.equals("DELETE")) {
return r;
}
...
return r;
}
But I still wonder what the correct way is...
Thanks.
-Simon
On Fri, May 13, 2011 at 5:14 PM, Simon Chen <si...@gmail.com> wrote:
> Hi all,
>
> I am trying to write a piece of javascript in an HTML page that will
> do a DELETE to a URL in a REST web service. However, my web service
> only gets OPTIONS requests for some reason.
>
> The html looks like this:
>
> <!DOCTYPE html>
> <html>
> <head>
> <script src="http://code.jquery.com/jquery-latest.js"></script>
> </head>
> <body>
> <form id="searchForm">
> <input type="text" name="s" />
> <input type="submit" value="Search" />
> </form>
> <div id="result"></div>
> <script>
> $("#searchForm").submit(function(event) {
> event.preventDefault();
> $.ajax({
> url: 'http://localhost:9000/test',
> type: 'DELETE',
> success: function(data) {
> alert('succeed');
> }
> });
> });
> </script>
> </body>
> </html>
>
>
> However, I got this for my webservice:
> INFO: Inbound Message
> ----------------------------
> ID: 53
> Address: /test
> Http-Method: OPTIONS <------SOMETHING WRONG HERE, in chrome>
> Content-Type:
> Headers: {Accept-Language=[en-US,en;q=0.8],
> Access-Control-Request-Headers=[Accept], connection=[keep-alive],
> Host=[localhost:9000],
> Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.3],
> User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24
> (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.24],
> accept-encoding=[gzip,deflate,sdch], Origin=[null],
> Access-Control-Request-Method=[DELETE], Content-Type=[null],
> Accept=[*/*]}
> -------------------------------------
>
> ID: 54
> Address: /test
> Http-Method: OPTIONS <------SOMETHING WRONG HERE, in firefox too>
> Content-Type:
> Headers: {Accept-Language=[en-us,en;q=0.5], connection=[keep-alive],
> Host=[localhost:9000],
> Accept-Charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.7], Keep-Alive=[115],
> User-Agent=[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1)
> Gecko/20100101 Firefox/4.0.1], Origin=[null], accept-encoding=[gzip,
> deflate], Access-Control-Request-Method=[DELETE], Content-Type=[null],
> Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]}
>
> Since the method is somehow OPTIONS, of coz, my webservice will
> complain "no cause is available". In the header, it shows
> "Access-Control-Request-Method=[DELETE]", but I don't know what it
> means. IE doesn't even bother to send out a request...
>
>
>
> Any ideas?
>
> -Simon
>