日期:2014-05-16 浏览次数:20365 次
<tbody style="line-height:20px;"> <tr>..</tr> <tr>..</tr> <tr>..</tr> <tr>..</tr> <tr> <td class="td2" width="48" height="50"> <td width="87">测试</td> <td>中国大陆</td> <td>吉林省四平市铁东区测试收货地址</td> <td>123456</td> <td class="td2"> <td class="td-a"> <span class="delBtn" style="cursor:pointer;" name="107">删除</span> </td> </tr> </tbody>
$(".delBtn").click(function () { var parms = '{id:"' + $(this).attr("name") + '"}'; $.ajax({ type: "post", url: "Ajax/DeliveryAddress.aspx/DeleteDeliveryAddress", data: parms, dataType: "json", contentType: "application/json; charset=utf-8", beforeSend: function (XMLHttpRequest) { }, success: function (data) { var result = eval(data.d)[0].result.toString(); if (result = "删除成功") { $(this).parent().parent().remove(); } alert(eval(data.d)[0].result); }, error: function (xhr, msg, e) { } }); });
$(".delBtn").click(function () { var parms = '{id:"' + $(this).attr("name") + '"}';//要么是个xx=xx的字符串,要么是个JSON对象,你现在都不知道是个什么东西。你用firebug等看到参数发送正确? $.ajax({ type: "post", url: "Ajax/DeliveryAddress.aspx/DeleteDeliveryAddress",//因为我没这个文件,所以我连你怎么错都不知道,你是数据库里面删不掉还是仅仅页面删不掉? data: parms, dataType: "json", contentType: "application/json; charset=utf-8", beforeSend: function (XMLHttpRequest) { }, success: function (data) { var result = eval(data.d)[0].result.toString();//json对象还要eval? if (result = "删除成功") { $(this).parent().parent().remove(); } alert(eval(data.d)[0].result); }, error: function (xhr, msg, e) { } }); });
------解决方案--------------------