I know this seems too complicated to take place, but I'm puzzled.
I have a page using jQuery's mail method to send an AJAX POST request to my API. They are both located on the same domain / server.
$.post('api/login.php', {username: 'test', password: 'test'}).done(function (res) { alert(res.response); });
The API looks like this:
<?php exit (json_encode(array ('response' => print_r($_REQUEST, true))));
This works as expected in my local WAMP setup, but on Bluehost it just shows Array () as if there were no parameters in the request.
If I change $.post to $.get , it gets both options just fine.
It also works as expected if I use an HTML form and submit data without using AJAX, for example.
<form method="post" action="api/login.php"> <input type="text" name="username" value="test"> <input type="text" name="password" value="test"> <input type="submit"> </form>
I think I have exhausted the tests that I can create to try to eliminate any other possibility, and it just comes down to something really strange - my PHP script does not receive the POST fields in the AJAX request.
source share