Edited data is saved successfully but Editor throws system error
Edited data is saved successfully but Editor throws system error
Link to test case:
Debugger code (debug.datatables.net): https://debug.datatables.net/uwuxil
Error messages shown: Ein Systemfehler ist aufgetreten
Description of problem:
I am using a custom function (with $wpdb->update) to save the data to my custom db tables (inside a WordPress install). The data is updated correctly but in Editor it shows a system error - however no logs are giving me any hint on what seems to be the issue. When closing the form and opening it up again, it shows the updated data.
What does Editor expect to be returned on edit success? As far as the docs show it expects the return data (I believe in the same json format it went in?). Does it also expect a "success" code or something?
This question has an accepted answers - jump to answer
Answers
A system error means the response from the server is invalid JSON. This page documents what Editor expects in return.
Using the network inspector in your browser, what is it currently returning?
Allan
Sleeping on it seems to have helped
I think there is a problem with the json encoding, it does return the right data, but with a lot of slashes etc. like
"{\"data\":{\"customer_id\":\"1\",\"user_id\":4,\"type\":\"staff\",\"firstname\":\"Regina\",\"lastname\":\"Gschladt\",\"company\":\"resQ online ...
- think I've added one too many json encode or something.Okay so now it doesn't throw an error anymore and closes the editor, but the edited row of the table is now gone Do I have to redraw the table after success? The rowID is set to the customer_id.
Could it be that the edited row is sorted off the current page?
Kevin
Assuming you have just JSON decoded that string from above, there is still an error in the JSON structure. The
data
property should be an array - e.g.:This is because of Editor’s multi-row editing capabilities - returning an array allows for multiple rows to have been edited.
Allan
Thank you, allan! Now it works perfect!