JQ 确定与取消弹出框,选择确定执行Ajax

  $(function () {
            $("#GetCoupon").click(function () {
                function del() {
                    var msg = "请确定领取吗?\n\n请确认!";
                    if (confirm(msg) == true) {
                        return true;
                    } else {
                        return false;
                    }
                }
                if (del()) {
                    var id = $(this).attr("did");
                    $.ajax({
                        type: 'post',
                        url: '/Home/Get',
                        data: { "id": id },
                        success: function (msg) {
                            console.log(msg);
                            if (msg) {
                                alert("领取成功");
                                window.location.reload();
                            } else {

                            }
                        }
                    })
                } else { alert("用户取消了领取"); }
            })
        })

 

posted @ 2018-04-13 12:15  紫晶城  阅读(724)  评论(0编辑  收藏  举报