I get a response from the page I'm trying to reach however $_POST is always empty. The GET equivalent works and so does posting using jQuery's AJAX. What the heck is going on here?
function search_now() {
var payload = JSON.stringify({ q: input_box.value });
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4) {
results_display.innerHTML = xhttp.responseText;
}
};
xhttp.open('POST', '/search-results/', true);
xhttp.setRequestHeader("Content-type", "application/json");
// xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhttp.send(payload);
}