I am trying to make a delete request using the jquery ajax method as follows
$.ajax(
{
type: 'DELETE',
url: '/tagz',
data: {id: taskId},
success: function(data)
{
console.log(data);
}
});
And when I see the console in chrome, I find in the request headers that instead of a DELETE request, a GET request is created. and in the firefox console I see the following.
23:50:52:658: Network: DELETE http://test.goje87.com/tagz [HTTP/1.1 301 Moved Permanently 947ms]
23:50:53:614: Network: GET http://test.goje87.com/tagz/ [HTTP/1.1 200 OK 400ms]
On the server side, I just support the following code.
$reqMethod = $_SERVER['REQUEST_METHOD'];
switch($reqMethod)
{
case 'GET':
Utils::printR('Will provide the resource.');
selectObjects();
break;
case 'POST':
Utils::printR('Will create a new record.');
createObject();
break;
case 'PUT':
Utils::printR('Will update the record.');
break;
case 'DELETE':
Utils::printR('Will delete the record.');
Utils::output($_SERVER);
break;
}
I do not see the request coming in case 'DELETE'. He gets in case 'GET'.
Below is the .htaccess file that I use on the server to clean up the urls.
RewriteEngine on
RewriteRule ^(.*)$ index.php [L,QSA]
Please help me make DELETE queries. Thank!
source
share