小编chi*_*hon的帖子

使用jquery ajax删除表中的记录

我正在学习j查询Ajax事件.我已经使用j查询Ajax在php中插入并显示记录但我无法删除记录我已编写代码但它无法正常工作,我不希望表再次加载.请帮助

TableName:登录

列:id,用户名,消息

comment.php

    <script type="text/javascript">
$(document).ready(function(e) {
 function showComment(){
     $.ajax({
     type:"post",
      url:"process2.php",
      data:"action=showcomment",
      success:function(data){
       $("#flash").html(data);
      }
    });
   }
showComment(); 

//Insert records 
$("#Submit").click(function(){

            if($(":text").val().length==0)
            {
               // $(this).next().html("Field needs filling");
               $(":text").after('<span class="errorkeyup">Field cannot be empty</span>');
                //return false;
                success = false;
            }
            else
            {
                var name=$("#name").val();
                var message=$("#message").val();
                $.ajax({
                  type:"post",
                   url:"process2.php",
                   data:"name="+name+"&message="+message+"&action=addcomment",                            
                  success:function(data){
                  showComment();                                  
                 } 
                }); 
            }

  });

$('.delete').click(function(e){
    e.stopPropagation();
            var deleteID = $(this).attr('name');
            var row = deleteID;
            $.ajax({
                type: "POST",
                url: "delete.php?deleteID=" + deleteID,
                data: "deleteID="+ deleteID,
                success: function(result){
                    $('#row'+row).fadeOut('fast');
                } …
Run Code Online (Sandbox Code Playgroud)

php jquery partial-page-refresh

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

jquery ×1

partial-page-refresh ×1

php ×1