菜单开关

周梦康 发表于 2018-01-24 1642 次浏览 标签 : javascript

<a href="javascript:;" data-aid="{{ article_info.raid }}" id="del_btn">删除</a>
  $("#del_btn").bind('click', function () {
    if (confirm("确定要删除?")) {
      var method = '/articles/destroy/' + $(this).attr("data-aid") + '/';
      Ajax.sendData({
        type: 'POST',
        url: method,
        async: false,
        dataType: "json",
        data: {},
        success: function (data, status, xhr) {
          //console.log(data);
          if (data.state == 'success') {
            location.href = '/articles/';
          } else {
            alert(data.msg);
          }
        },
        error: function (xhr, type, error) {
          console.log(error.toString());
        }
      });
    }
  });

<a href="/articles/destroy/{{ article_info.raid }}" class="_article-op" data-method="get" data-confirm="确定要删除?">删除</a>

评论列表