I'm currently trying to implement the handling of an HTTP 413: Request entity too large error from my server. What I've done is this:
$.ajax({
url: "submit.php",
data: {
"data": POSTData
},
success: function(response, statusText, XHR) {
console.log(XHR.status + ": " + response);
resolve(); // resolve the promise and continue on with execution
},
// Added this part:
error: function(response, statusText, XHR) {
if(XHR.status === 413) {
// Request entity too large
// To solve this we split the data we want to upload into several smaller partitions
// and upload them sequentially
console.log("Error 413: Request entity too large. Splitting the data into partitions...");
// handling code below
// blahblahblah
}
},
method: "POST"
});
But instead of the error callback being fired, my console still throws an error (it says it's a 413), as if there's no handler. How do I implement this functionality?