0

I have HTML page which contains a Editable table, Where I am fetching the data from database using PHP and inserting into the that table. As my table is Editable, I want to update the values into the database when the user update any row value.

Please suggest me,because I don't know how to make AJAX call when user edits and click anywhere on browser.

4

1 Answer 1

2

You have to catch the moment where the datas are saved in your datatable: Often a click on a button. So you need a code like that :

$(document).ready(function(){
 $('#save-row-4').on('click', function(){
   // Your ajax call here
 });
});

The ajax have to be like :

$.ajax({
    url: '/path/to/php/script.php',
    type: 'POST',
    data: {
       variable1: 'val1',
       variable2: 'val2',
       variable3: 'val3'
    },
    error: function(return) {
        alert("error");
    },
    success: function(return) {
        console.log("Datas saved");
    },
});

Don't forget to replace val1, val2 with the value of your inputs. Then, in your php script, you will be able to get these datas with $_POST['variable1'] .

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot. That solves my problem. I got idea to proceed
No problems :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.