【发布时间】:2016-09-01 14:48:46
【问题描述】:
我目前正在尝试处理来自我的服务器的 HTTP 413: Request entity too large 错误。我所做的是这样的:
$.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),就好像没有处理程序一样。如何实现此功能?
【问题讨论】:
-
@karacsi_maci 谢谢,这绝对是一个不错的选择。如果可以的话,我宁愿在客户端处理它,但如果证明太困难,那么我将不得不求助于更改服务器设置。
标签: javascript jquery ajax