I am using Jquery to do POST to authenticate my page.
$.post("api/authenticate", {"authkey": authkey}, function(data){
console.log(data);
if (data.success === "false") {
window.location="/Login.html";
}
});
EDIT!!
If authentication is unsuccessful, my php function will return a json object
{"success":"false"}
However, the console.log(data) does not return me anything. even though I can see the response in the resource.
Anyone knows how can I solve this?
Any help is greatly appreciated.
Freon’s answer probably works, here’s an alternative, try forcing the
dataTypeto JSON.Another think to look for is to make sure your server responds with a 2xx status. If you return a different status,
jQuerywill not try to read the response. It will instead look for status code handlers set in thestatusCodeoption that is passed to http://api.jquery.com/jQuery.ajax/Example