ajax post to PHP server $_POST always empty

  • 0 Replies
  • 2555 Views
ajax post to PHP server $_POST always empty
« on: May 23, 2016, 20:03:53 pm »
I've been trying to send a ajax request of a login form to php endpoint

Code
$.ajax({
    type: "POST"
    , url: "restapi.php"
    , data: "id=1&action=login" 
    , success: function(html){

    }
});

but when I debug the server $_POST is always empty for some reason
even though I can retrieve the JSON data from
Code
file_get_contents('php://input');

and $_SERVER['REQUEST_METHOD'] == 'POST' returns true
I don't understand why the $_POST variable is always empty

 

Sitemap 1 2 3 4 5 6 7 8