1. 程式人生 > >Ajax實現模態框的呼叫與資料刪除

Ajax實現模態框的呼叫與資料刪除

$("#btDelete").click(function () {
        //Modal frame
        if (id == null) {
            $("#myModalLabel").html('ERROR');
            $("#ModalLabel").html('Please input hotel name!');
            $('#DeleteModal').modal({
                backdrop: 'static'
            })
            return false;
        } else {
            //Delete data 
            $.ajax({
                type: "DELETE",
                url: _url + "/" + id,
                dataType: "json",
                success: function (data) {
                    window.location.reload();
                    console.log('success,');
                }, error: function () {
                    console.log('fail,');
                }
            })
            return false;
        }
    });