Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35273

Loading data via ajax broke other code to delete a row.

$
0
0

I have the following code to make an ajax call to a php file that performs a delete of the record.

        $('#btnDelete').click( function () {
            if (confirm('Are you sure want to delete this record?')) 
            {           
                $.post("deleteChemData.php",   // FAILING HERE
                  {
                    id: id  
                  },
                  function(output, status){
                    if (output==1)
                    {
                        // Remove the row from the table
                        t.fnDeleteRow(aRowToDelete); 
                        alert("Record Deleted!");
                    } else {
                        alert("An error was encountered while attempting the record delete.");
                    }
                  });

            }
        });

This code was working fine before I changed the way I am populating the data from PHP code in the table to ajax. As soon as the debugger hit the $.post line it fails. Anybody have ideas?

I changed this to use $.ajax rather than $.post and it is working now:

                $.ajax({
                    type: "POST", 
                    url: "deleteChemData.php",
                    data: 'id=' + id, 
                    success: function(output, status)
                    {
                        if (output==1)
                        {
                            // Remove the row from the table
                            t.fnDeleteRow(aRowToDelete); 
                            alert("Record Deleted!");
                        } else {
                            alert("An error was encountered while attempting the record delete.");
                        }
                    }
                });         

Viewing all articles
Browse latest Browse all 35273

Trending Articles