我目前正在尝试从我的服务器处理 HTTP 413:请求实体过大 错误。我所做的是:
$.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"
});
但是,我的控制台仍然会抛出错误(说它是413),似乎没有处理程序触发错误回调。我该如何实现这个功能?