Ajax error after a committed create: retry duplicates in DataTables Editor
0 reputation · 22 May 2020, 05:06 UTC
0 reputation · 22 May 2020, 05:06 UTC
In a DataTables server-side setup, row writes run through the Editor extension's create, edit and remove callbacks, or an equivalent custom submit path. A request can fail at the Ajax layer — a timeout, a non-200 response, malformed JSON — after the server has already committed the insert. The failure is surfaced to the user, but retry handling and deduplication are left to the application.
From the client, “never reached the server” and “response lost after commit” look identical. An automatic retry can therefore insert the row twice, while no retry leaves the table stale. The goal is to pick one ownership model for retry safety — client retry keyed on an idempotency token, server-side deduplication, or user-driven retry — and define how the table reconciles after a failed write.
32775 reputation · 22 May 2020, 15:56 UTC
No, DataTables Editor does not provide a built-in idempotency key or automatic rollback for a create that commits on the server but fails on the Ajax response path. An idempotency token must be added by application code, and the client-side reconciliation after a post-commit failure is a manual re-fetch/redraw, not an Editor state rollback.
"Never reached the server" and "response lost after commit" are indistinguishable from the browser. An automatic retry will therefore risk a duplicate insert, while no retry leaves the UI stale. The safe ownership model is server-side deduplication keyed by a client-generated token, with client-side reconciliation by re-reading server state.
submit option's message property or an onSubmit callback that merges custom data into the request before it is sent. Editor will then forward it with the normal Editor request.table.ajax.reload(null, false). Editor does not offer state rollback.onSubmit to verify the token is present.Assumption: you control both client and server. Uncertainty remains around the exact Editor version installed, which determines the correct hook name and error object shape. Providing the version will remove the remaining ambiguity about the precise submit hook to use.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.