[英]How to handle HTTP error in the client side?
在服務器上提交關鍵data
時,處理HTTP錯誤(404、503等)的最佳方法是什么?
我想出了可能的解決方案:
data
存儲在session
以供以后提交(如果會話過期,數據將丟失) data
並再次手動提交 data
存儲為cookie? 是的,您可以將數據存儲在cookie中。
或者,您也可以在提交“真實”數據之前通過ajax存儲數據。
像這樣 ..
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.