[英]How to handle HTTP error in the client side?
What is the best way to handle HTTP errors (404, 503, etc.) when submitting a crucial data
on the server? 在服务器上提交关键data
时,处理HTTP错误(404、503等)的最佳方法是什么?
Possible solutions I came up with: 我想出了可能的解决方案:
data
stored in the session
for later submission (data is lost if session expired) 将data
存储在session
以供以后提交(如果会话过期,数据将丢失) data
downloaded by the user and manually submit it again 由用户下载data
并再次手动提交 data
as cookie? 是否可以将data
存储为cookie? Yes, You can store data at cookie. 是的,您可以将数据存储在cookie中。
Or you can store data by ajax before your 'real' data submit. 或者,您也可以在提交“真实”数据之前通过ajax存储数据。
like this .. 像这样 ..
function doSubmit() { // It will store the crucial data at server side. try { $.ajax({ ... url : /temporary/storeData.do, data : { // Your crucial data will be located here. }, ... }); } catch (e) { // Error Handling for '$.ajax.error'. return; } // It's your real submit. document.aform.submit(); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.