简体   繁体   English

jQuery AJAX load() div 表加载后按钮不工作

[英]jQuery AJAX load() div table after loaded buttons are not working

currently having this problem, I have ajax request to send form datas and save it to database and after saving I then use load() function to refresh the list in table, but after being loaded the button inside the loaded div is not working which also uses js.目前有这个问题,我有 ajax 请求发送表单数据并将其保存到数据库,保存后我使用 load() function 刷新表中的列表,但加载后加载的 div 内的按钮不起作用这也使用 js。

Ajax Ajax

var formData = new FormData(this);

    $.ajax({
        url: "/systemadmin/storemanagement/"+id,
        method: "POST",
        data:formData,
        cache:false,
        contentType: false,
        processData: false,
        success:function(data){

            console.log(data)

            $("#storeDatatable").load(location.href + " #storeDatatable");

            $(".message-error").remove();
            $(".message-success").remove();

            $('#store-update-header').append('<div class="message-success">Update succesfully</div>');

        }, error:function (err) {

            if (err.status == 422) {

                console.log(err.responseJSON);
                $(".message-error").remove();
                $(".message-success").remove();

                $.each(err.responseJSON.errors, function (i, error) {
                    $('#store-update-header').append('<div class="message-error">'+error[0]+'</div>');
                });
            }
        }
    });

solved by using通过使用解决
$(document).on('click','.toggleModal-updateStore', function(){ })
instead of代替
$('.toggleModal-updateStore.').on('click', function(){ })
for the buttons inside the row对于行内的按钮

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM