$("#am-pic").on("click",".am-pic-minus",function(){
alert($("div i img ").attr("src"));
$(this).parent().remove();
var pic_address=$("div i img ").attr("src");
alert(pic_address);
jQuery.ajax({
type:"POST",
data:{pic_address:pic_address},
url:"/PublishController/doUpdate"//刪除
,dataType:'json',
success:function(data)
{
alert("刪除成功");
window.location.reload();
}
else{
alert("刪除失敗,請稍候重試");
return false;
}
});
});
還有你的代碼放在 am-pic下面了沒有。。要不會找不到對象無法添加點擊事件,否則就改為document
$("#am-pic").on("click", ".am-pic-minus", function () {
alert($("div i img ").attr("src"));
$(this).parent().remove();
var pic_address = $("div i img ").attr("src");
alert(pic_address);
jQuery.ajax({
type: "POST",
data: { pic_address: pic_address },
url: "/PublishController/doUpdate"//刪除
, dataType: 'json',
success: function (data) {
alert("刪除成功");
window.location.reload();
}
////////////////////////是error配置,怎麼搞個else在裡面,如果是依據success中的data返回值,自己改為if...else判斷
/*else*/, error: function () {
alert("刪除失敗,請稍候重試");
return false;
}
});
});