layerUi与AJAX的一种思路
javascript:
function rep(id) { layer.confirm("确定要拒绝此认证吗?", { btn: ["确定", "取消"] }, function () { var url = document.getElementById("repulse-url").value; $.ajax({ type: "POST", url: url, data: { ids: id }, dataType: "json", success: function (data) { if (data == 0) { layer.msg("操作成功!", { icon: 1 }); setTimeout("location.reload()", 1000); } else { layer.msg("操作失败!", { icon: 2 }); } }, error: function () { layer.msg("系统错误!", { icon: 2 }); } }); }); }
[HttpGet] public ActionResult Index() { ViewBag.DeleteUrl = "地址"; return View(); }
<td> <div class="operate"> <a href="javascript:;" class="gray" onclick="pas(@item.Id)" >通过认证</a> <a href="javascript:;" class="red" onclick="rep(@item.Id)">拒绝认证</a> </div>
</td> <input type="hidden" id="repulse-url" value="@ViewBag.RepulseUrl" /> <input type="hidden" id="pass-url" value="@ViewBag.PassUrl" />