The below code snippet was working fine, but it stopped all of a sudden for no apparent reason
jQuery.ajax({
url: "http://example.com/api/getstuff.php?Location="+location+"&token="+token,
type: 'GET',
dataType: 'json',
success:function(data){
if(data.success == '0'){
alert("success");
}
else
{
alert(data.error);
}
});
when I copy the url of api being called from inspector and open in the browser it works fine, it was working fine both on development and production. any ideas?
*edit The issue was fixed, the api call was missing www so the call was redirected to use www, hence the 301 error.
Though this fixed the problem but I'm unable of explaining because this was the way used long ago, suddenly it stopped working!
Anyways I thought I should post the fix so someone can find useful.
Thanks
Is this your API or a third-party API? This status code means that this resource was permanently moved to a new URL and can't be reached in this URL anymore. If it's not your own API, you must check the Location header to get the new resource location. Use the inspector to check this header out.
Just to clarify, take a look at the RFC below:
Link: https://www.rfc-editor.org/rfc/rfc7231#section-6.4.2
This part talks about the Location header ->