[Editor] Server response
[Editor] Server response
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
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
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 :
I have this error :
TypeError: json.fieldErrors is undefined
on "dataTables.editor.js" at line 4192.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.
Good to hear you got it sorted :-)
Allan