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

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

donblaylockdonblaylock Posts: 10Questions: 4Answers: 0
edited June 2014 in Free community support

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.");
                        }
                    }
                });         

Answers

  • donblaylockdonblaylock Posts: 10Questions: 4Answers: 0

    I changed this to use $.ajax instead of $.post and that fixed it!

                    $.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.");
                            }
                        }
                    });         
    
This discussion has been closed.