I've been reading some guides regarding REST in PHP and JavaScript. I'm facing a small implementation problem.
Assuming that I want to delete my server side to behave according to the received URI. for example:
If it receives on http DELETE
URI: /users/563
it will delete user with the ID 546
My problem starts with the DELETE request on client side (JavaScript):
function ajaxRequest()
{
var http_request = new XMLHttpRequest();
http_request.onreadystatechange = function()
{
var done = 4, ok = 200;
if (http_request.readyState == done && http_request.status == ok)
{
responseHandler(http_request.responseText);
}
};
http_request.open("DELETE", php/dbHandler.php , true);
http_request.send(data);
}
In the delete request I must specify the url of the server side in that case it is dbHandler.php
Where should I insert the URI /users/563
without losing the server-side destination address?
On server side if I try to extract URI with the command $_SERVER['REQUEST_URI']
I will always get php/dbHandler.php
what is the proper way to create/send the URI in client side and extract it in server-side?