weixin_33713707 2011-06-05 13:21 采纳率: 0%
浏览 15

模式对话框内的Ajax调用

<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?

  • 写回答

1条回答 默认 最新

  • weixin_33698823 2011-06-05 13:34
    关注

    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 .

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog