Edited data is saved successfully but Editor throws system error

Edited data is saved successfully but Editor throws system error

resqonlineresqonline Posts: 58Questions: 14Answers: 0

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

  • allanallan Posts: 61,722Questions: 1Answers: 10,108 Site admin

    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

  • resqonlineresqonline Posts: 58Questions: 14Answers: 0

    Sleeping on it seems to have helped :D
    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.

  • resqonlineresqonline Posts: 58Questions: 14Answers: 0

    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.

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769

    but the edited row of the table is now gone

    Could it be that the edited row is sorted off the current page?

    Kevin

  • allanallan Posts: 61,722Questions: 1Answers: 10,108 Site admin
    Answer ✓

    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.:

    {
      “data”: [
        {
          “customer_id”: 1,
          “user_id”: 4,
          …
        }
      ]
    }
    

    This is because of Editor’s multi-row editing capabilities - returning an array allows for multiple rows to have been edited.

    Allan

  • resqonlineresqonline Posts: 58Questions: 14Answers: 0

    Thank you, allan! Now it works perfect! B)

Sign In or Register to comment.