Jump to content

Recommended Posts

I am sending a DELETE request in backbone using:

 

this.model = new domain.city.delete_photo.Model();

this.model.url = "/assets/ajax/delete_image.php?img_id="+id;

this.model.id = id;
this.model.destroy({
						 "success" : this.success,
						 "error" : this.error
						 });

 

And that sends a DELETE request to the server with the URL something like:

 

http://localhost/ass...ge.php?img_id=9

 

The problem is, I can't seem to access the img_id. In my ajax file I have:

 

$_DELETE = array();
if($_SERVER['REQUEST_METHOD'] == 'DELETE') {
 parse_str(file_get_contents('php://input'), $_DELETE);
}
print_array($_DELETE);

 

Why doesn't this work? The array returns empty!

Edited by unemployment
Link to comment
https://forums.phpfreaks.com/topic/271268-php-using-http-delete-and-backbone/
Share on other sites

"DELETE" is not a valid 'REQUEST_METHOD'. Allowed REQUEST_METHOD's: 'GET', 'HEAD', 'POST', 'PUT'.

It most certainly is valid. So are OPTIONS and TRACE and CONNECT.

 

OP: Are you sure $_GET is empty? I'd expect it to have your img_id just fine.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.