How do i set the content-type to application/json from text/html in response header i already set the request header content type to application/json but the response header content-type shown in text/html
here is my code
function check(c2) {
document.title = 'Checking';
var xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var xdata = xmlhttp.responseText;
if (xdata.match("GOOD")) {
$("#GOOD").append(xdata);
document.getElementById("goodcnt").innerHTML = (eval(document.getElementById("goodcnt").innerHTML) + 1);
$("#listcnt").html(parseInt($("#listcnt").html()) - 1),
line('#cs');
Check();
} else if (xdata.match("BAD")) {
$("#BAD").append(xdata);
document.getElementById("badcnt").innerHTML = (eval(document.getElementById("badcnt").innerHTML) + 1);
$("#listcnt").html(parseInt($("#listcnt").html()) - 1),
line('#cs');
Check();
}
}
}
xmlhttp.open("POST","api?list=" + c2 ,true);
xmlhttp.setRequestHeader("Content-Type","application/json");
xmlhttp.send();
}
i also tried to add this code in api
header("Content-Type: application/json");
api
and im getting message that my json is malformed – Jason LoperaInput could not be parsed
i get this curl response instead of getting theinvalid
message – Jason Lopera