向jQuery模态发送ajax成功响应

时间:2022-10-09 11:37:37

How to send ajax success response to jQuery Modal (jQuery Modal Site) when i click submit and automatically show modal with response. This is my ajax to post:

如何在单击submit后将ajax success响应发送到jQuery模态(jQuery模态站点),并自动显示带有响应的模态。这是我要发布的ajax:

$('#rincian').submit(function() {
    $.ajax({ 
        data: $(this).serializeArray(),
        type: $(this).attr('method'), 
        url: $(this).attr('action'), 
        success: function(response) { 
            $('#rinci').html(response); 
        }
    });
    return false; 
});

UPDATE Answered by Jossef

更新内存泄漏问题回答

I have changed it to $('#rinci').html(response).modal();

我已经将它改为$('#rinci').html(response).modal();

$('#rincian').submit(function() {
    $.ajax({
        data: $(this).serializeArray(),
        type: $(this).attr('method'),
        url: $(this).attr('action'), 
        success: function(response) {
            $('#rinci').html(response).modal();
        }
    });
    return false;
});

1 个解决方案

#1


3  

http://jsfiddle.net/5WEVL/

http://jsfiddle.net/5WEVL/

$('#clickme').click(function() {
    $.ajax({ 
        url: '', 
        success: function(response) { 
            $('#modal-div').html(response).modal();
        }
    }); 
});

add .modal(); and it should work

添加.modal();它应该工作

#1


3  

http://jsfiddle.net/5WEVL/

http://jsfiddle.net/5WEVL/

$('#clickme').click(function() {
    $.ajax({ 
        url: '', 
        success: function(response) { 
            $('#modal-div').html(response).modal();
        }
    }); 
});

add .modal(); and it should work

添加.modal();它应该工作