What is the best way to handle HTTP errors (404, 503, etc.) when submitting a crucial data
on the server?
Possible solutions I came up with:
data
stored in the session
for later submission (data is lost if session expired) data
downloaded by the user and manually submit it again data
as cookie? Yes, You can store data at cookie.
Or you can store data by ajax before your 'real' data submit.
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(); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.