开发者

Ajax call inside modal dialog

开发者 https://www.devze.com 2023-03-10 18:13 出处:网络
<script> $(function() { $(\'#clickMe\').click(function(event) { var mytext = $(\'#myText\').val();
<script>
$(function() {

$('#clickMe').click(function(event) {
var mytext = $('#myText').val();


$('<div id="dialog"></div>').appendTo('body');            
    event.preventDefault();


            $("#dialog").dialog({                                   
                    width: 600,
                    height:300,
                    modal: true,
                    close: function(event, ui) {
             开发者_高级运维               $("#dialog").remove();
                            }
                    });
}); //close click
});

How can I implement an ajax call inside the modal dialog?


The modal dialog is nothing but a DIV/HTML element on your page .

Its hidden by default and when the user click on a button the modal is called and it shows up on top of the page .

You can add ajax to it the normal way

For Example

<div id="dialog">
   <a id="click" href="#">click me</a>
   <span id="after_ajax"></span>
</div>

--

$('#click').live('click', function(){
 $.post('',function(data){
   $('#after_ajax').html(data);
 });

});

Note I am binding the #click to a live event because I can see that you are adding the #dialog dynamically via jQuery .

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号