I have the following scenario: - a simple html page with a form and some "fields" - when the form is submitted it is performed a GET to a specified URL that replies "302" and the url where the user has to be redirected too is in "Location" header - i checked with fiddler and evetything seems correct
The simple html page includes this piece of code:
function doSubmit() {
var _url = $("#url").val();
$.ajax({
url: _url,
complete: function(xmlHttp) {
// xmlHttp is a XMLHttpRquest object
alert(xmlHttp.status);
}
The problem is that when submitting the request, i receive as statuscode: 0 and i'm not able to retrieve any "Location" header.
UPDATE
I tried using the Fetch API but it seems it doesn't work:
var req = new Request(url, {
method: 'get',
redirect: 'manual',
"Cache-Control": "no-cache"
});
fetch(req).then(function (res) {
alert(res.status);
}, function (e) {
alert('error');
});
It always ends into an error.