calling a php-file from within the editor.on-postSubmit event

calling a php-file from within the editor.on-postSubmit event

maidenmaiden Posts: 16Questions: 6Answers: 0

Hi,
I'm working on an intranet site using datatables editor and everything works fine so far. The Editor::inst selects data from 3 database tables, lets say table A leftjoin B leftjoin C, everything fine so far. Now when a specific select field in the editor is changed I need to update a 4th table, lets say table D. Like in the last answer of this post
https://datatables.net/forums/discussion/64220/how-to-get-changed-fields-in-the-presubmit-event-handler
I'm comparing the values of the select field and if it has changed I also need to update the table D, which is located in the same database, but not part of the Datatable or editor instance. So according to the above mentioned post , I want to call a php file that does the update inside the on(initSubmit)-event (or probably another event);

.on('initSubmit', function ( e, action ) {
if ( old_value != new_value) .... CALL THE PHP file
...
I tried several things but they didn't work. Can you please give me a hint how to achive what I want?
Thank you in advance,
martin

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,550Questions: 1Answers: 10,476 Site admin
    Answer ✓

    Hi Martin,

    The way to do that would be an Ajax call to the server using $.ajax() or fetch if you want to use the latest Javascript APIs :).

    However, I would actually suggest that rather than making this extra Ajax call, why not just do the update at the server. Are you using our PHP libraries? If so use the events it triggers to execute code that will update your db as needed. That will save you a file and extra network activity.

    Allan

  • maidenmaiden Posts: 16Questions: 6Answers: 0

    Hi Allan,
    thank you for your reply. Problem solved :smile:
    regards, martin

Sign In or Register to comment.