Call a post in Ajax

0 thích 0 không thích
1 lượt xem
đã hỏi 26 Tháng 5, 2022 trong Lập trình Web bởi dinhtona (1,120 điểm)
$('.edit-item').click(function () {
            var id = $(this).attr('iditem');
            $.ajax({
                url: subDomainUrl + '/' + '@ViewData["EditUrl"]',
                contentType: 'application/html; charset=utf-8',
                data: { id: id },
                type: 'GET',
                dataType: 'html'
            })
                .done(function (result) {
                    $('#modal-body-edit').html(result);
                    $('#modal-edit').modal();
                })
                .fail(function (xhr, status) {
                    alert(status);
                })
        })
    

2 Câu trả lời

0 thích 0 không thích
đã trả lời 27 Tháng 5, 2022 bởi nguyenthao (9,000 điểm)
Quá mạnh mẽ bạn ơi.
0 thích 0 không thích
đã trả lời 27 Tháng 5, 2022 bởi dinhtona (1,120 điểm)
<!--Loading-->

    <div id="divloading" style="margin: 0px; padding: 0px; position: fixed; right: 0px;
        top: 0px; width: 100%; height: 100%; background-color:#ffffff; z-index: 300001;
        opacity: .8; filter: alpha(opacity=80);display:none">
        <div style="position: absolute; top: 40%; left: 50%; color: black;">
            <img style="width:60%" src="~/dist/img/loading.gif" />
        </div>
    </div>

<!--Show the loading-->

 function Searching() {
            if ($("#FilterForm").valid()) {
                $.ajax({
                    url: subDomainUrl + '/MIXDashboard/Searching',
                    type: 'POST',
                    data: $('#FilterForm').serialize(),
                    beforeSend: function () {
                        // Show image container
                        $("#divloading").show();
                    },
                    success: function (data) {
                        $('#MainTable').html(data);
                    },
                    error: function (xhr, status, error) {
                    },
                    complete: function (xhr, status) {
                        $("#divloading").hide();
                        //$('#mixmaster-area').html("");
                        $('#mixdetail-area').html("");
                        InitMixTable();
                    }
                });
                sessionStorage.clear();
            };
        }
đã bình luận 27 Tháng 5, 2022 bởi nguyenthao (9,000 điểm)
Nếu sử dụng bất đồng bộ, Async/Await.

=> Nên chuyển jquery Ajax => thư viện Axios
đã bình luận 28 Tháng 5, 2022 bởi dinhtona (1,120 điểm)
Cú pháp này là call async mà
...