$.ajax with DELETE loses parameters

jquery

Solution

Interesting. I can't find anything in the RFC but it stands to reason that there is no way to pass parameters using the DELETE methods - only in GET and POST, so either JQuery or the browser correctly filter out the parameters. This is just a guess, though, maybe somebody who knows this stuff by heart can make a more profound statement.

Anyway, if this is how JQuery works right now, I think your workaround will have to be putting the ID into the URL, and mod_rewrite it out.

Before you do that, try whether you can't trick the browser in passing it through by adding the parameter to the URL: `sitesCtrl.url+'?ID='+id`

Problem

In my client app—written in javascript and jQuery—I have a function where I'm doing $.ajax request with the DELETE method to my server. The code is something like this: ``` this.delete_one = function(id){ console.log(id); $.ajax({ url: sitesCtrl.url, type: "delete", dataType: 'json', data: {"id": id}, success: function(data){ if (data.success){ $("sitesList").remove("#" + id + "\""); } else{ console.log(data.message); } }, error: function(){ console.log("internal error"); } }) }; ``` The problem is that the server gets the request with no parameter "id"! Just a simple DELETE (according to firebug). with PUT, POST, or GET it works great.

Original source

Related problems