在函数中调用删除页面

时间:2014-03-05 02:51:39

标签: jquery

我的页面中有一个功能,即删除一行表格:

$('#lista').on('click', '.menos', function () {
   if ($('#lista tbody').children('tr').length > 1) {
      if (confirm("Are you sure?")) {
         $(this).closest('tr').remove();
         $(':input[name^="preco"]').trigger("keyup");
         var trid = $(this).closest('tr').attr('id');
         // i need to call a page deleteItem.php?id= trid
      }
  } 
  else 
  {
      alert("You must have at least one product.");
  }
});

基本上我需要在按下删除按钮后立即调用删除页面。

有什么想法吗?

编辑:

PHP文件:

include "conexao.php";
$id = $_GET['id'];
$id = mysql_real_escape_string($id);
mysql_query("DELETE FROM itenspedido WHERE idItensPedido = '".$id."'");

1 个答案:

答案 0 :(得分:1)

您可以在此处使用 $.ajax(

var trid = $(this).closest('tr').attr('id');
$.ajax({
    type: "GET",
    url: "deleteItem.php",
    data: "id="+trid,
    success: function (data) {
        // Code 
    }
});