AJAX fetch request failing with 500 internal server error
Posted on April 25, 2026, 2:18 pm • 404 Views
TechNoob
Member
Rep: 10
Posted on April 25, 2026, 2:18 pm
Sending a POST request via JS Fetch API, but the PHP backend crashes.
Twonk9098
Admin
Rep: 9999
Replied on April 26, 2026, 10:47 am
If you used `fetch()`, it sends data as a JSON payload, NOT as form-data. PHP's `$_POST` array will be empty. You must read the data using `json_decode(file_get_contents("php://input"), true);`.