Jump to content

Php Using Http Delete And Backbone


unemployment

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!

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.