tags:

views:

105

answers:

3

Is it possible to use a custom HTTP VERB, like MERGE, with jQuery.ajax()? I'm interacting with an OData API, which expects a MERGE verb when posting updates to records.

The problem I'm having is that when I use "MERGE" in the ajax() request, it doesn't send data to the server. It just sends a MERGE request with no data, so the OData service rejects it.

When I change the request to a PUT, the OData service sends back a 500 error.

My options are basically to figure out how to get "MERGE" calls to send the data along with the request, do a DELETE followed by a POST (delete and recreate the record on every update), or figure out how to modify the OData service to accept PUTs for updates.

Let me know if you have any ideas on how to make jQuery.ajax() send the data with a MERGE request.

Thanks,

Dave

+3  A: 

This is not a question of jQuery's ability to handle custom HTTP verbs, this depends on the browser.

Jacob Relkin
Jacob's correct, it's not jQuery stopping you here but the browser's implementation of XmlHttpRequest. For example, IE doesn't support `PUT` either.
Nick Craver
+1  A: 

Found through this question, here is a blog article that looks interesting.

The answer - at least in 2008 - if I read it correctly:

  • IE seems not to support it (at least up to Version 7)

  • Firefox supports it

  • Opera turns everything unknown into a GET request

I think you'll have to try it out.

Pekka
+4  A: 

OData supports tunneling MERGE through POST - which of course is supported via JQuery - by adding the X-HTTP-Method header.

See this thread for more

Alex

OData Program Manager Microsoft

Alex James
Thanks! This is exactly what I was looking for.
Dave Morris