[Editor] Server response

[Editor] Server response

FlorianeFloriane Posts: 22Questions: 6Answers: 0

Hi,

I'm using Editor with Symfony 2 to edit datas from an XML database. The database structure can change so I have to initialise Editor with a dynamic reading of the database.

My question is about the simple edition. I make an ajax call like that :

var editor = new $.fn.dataTable.Editor( { 
                           ...
     ajax: function ( method, url, data, success, error ) {
            if ( data.action === 'edit' ) {
                $.ajax( {
                    type: 'POST',
                    url:  '../myScript.php',
                    data: {datas: JSON.stringify(data)},
                    success: function (json) {                        
                        success( json );
                    },
                    error: function (xhr, error, thrown) {
                        error( xhr, error, thrown );
                    }
                } );
            }
        }    
    });

But, what I'm suppose to return on myScript.php to obtain a correct json object on success ? (After I have saved my datas on XML files). Can I use Editor::inst even if I can't define the Field::inst ?

Thank's.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,683Questions: 1Answers: 10,498 Site admin

    Hi,

    The Editor client / server communication protocol is documented in the manual. If you are implementing your own server-side scripts to interface with Editor, that will give you the information required.

    Any questions about it, let me know!

    Allan

  • FlorianeFloriane Posts: 22Questions: 6Answers: 0
    edited May 2015

    Thank's Allan for you reply. I'm implementing my own server-side like you said.

    So, my send to the Server is correct, and my return seems to be good too. This is my json return :

    {
       "row":{
           "DT_RowId" : "row_7",
           "1" : "Pierre",
           "2" : "Walter",
           "3" : "16",
           "4" : "",
           "5" : "32000",
        }
    }
    

    I have this error : TypeError: json.fieldErrors is undefined on "dataTables.editor.js" at line 4192.

    if ( json.error || json.fieldErrors.length ) { ...
    

    However, fieldErrors is optionnal parameter according to the manual. So, why this error occured ? Am I supposed to define fieldErrors, an empty array ?

    EDIT : I found my problem... On ajax return I forgot to parse my json return. So now it's ok.

  • allanallan Posts: 63,683Questions: 1Answers: 10,498 Site admin
    Answer ✓

    Good to hear you got it sorted :-)

    Allan

This discussion has been closed.