D
D
dicem2016-01-16 02:30:03
PHP
dicem, 2016-01-16 02:30:03

Why doesn't asynchronous deletion of rows from sql table work?

The people implemented removal of a line from the table of a DB. In terms of deletion, everything works, but not asynchronously, as I did not try. Please help me figure it out.
The form:

<form id="delForm" method="post" action="journal_del.php">
  <input type="text" class="hidden" name="unic" id="unic" value="'. $data['id'] .'" />
  <button id="del_btn" class="btn btn-md btn-warning">Удалить</button>
</form>

Request:
include_once('db.php');
$unic_id = $_POST['unic'];
if (mysql_query("DELETE FROM test_kek WHERE `id`='".$unic_id."' "))
  echo '<div class="alert alert-success" role="alert">Успешно удалено</div>';
else
  echo '<div class="alert alert-danger" role="alert">Что то пошло не так :(.</div>';

jQuery:
$("#del_btn").click( function(){

  $.post( $("#delForm").attr("action"), $("#delForm :input").serializeArray(), function(info){ 
    $('#ajax_res').load('content.php');
  });

});

$("#delForm").submit( function(){
  return false;
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question