I am posting using xmlhttprequest as follows
// xhr response handler
xhr.onreadystatechange = function () {
if (xhr.status == 200 && xhr.readyState == 4) {
handleSuccess(xhr.responseText);
} else if (xhr.status == 400) {
console.log("400000000000000000000");
// alert("Unable to process data");
// window.location.reload();
sendRequestSimple("400.html");
// fetch("/400")
// .then(function() {
// console.log("ok");
// }).catch(function() {
// console.log("error");
// });
}
else {
console.trace("status: " + xhr.status);
console.trace("readystate: " + xhr.readyState);
}
};
// Send the Data.
xhr.send(formData);
I am unable to get it to redirect to 400 error page in an error scenario. What is the correct way? As coded above..it will not redirect.
Many thanks in advance
Aucun commentaire:
Enregistrer un commentaire