Error fetching Ajax data via $_POST

When fetching some data via ajax you need to check the Request Headers Content-Type. If Content-Type is not set as below the $_POST will not be able to fetch data.

$.ajax({
url: “Some server side url”,
type: “POST”,
data:{userEmail : email},
headers: {
‘Authorization’: ‘Bearer ‘,
‘cache-control’: ‘no-cache’,
‘content-type’: ‘application/x-www-form-urlencoded; charset=UTF-8
},
success: function(response)
{
//console.log(response);
}
error: function(xhr, status, error) {
console.log(“Error”+error);
return;
}
});

Share via
Copy link
Powered by Social Snap