在jQuery模式对话框onclick中加载外部php文件 [英] Load external php file in jquery modal dialog onclick

查看:73
本文介绍了在jQuery模式对话框onclick中加载外部php文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户单击链接时,我正在尝试打开一个jQuery模式对话框.然后,我想将一个外部php文件加载到对话框中.我正在使用这个jquery:

I'm trying to open a jquery modal dialog box when the user clicks on a link. I'd like to then load an external php file into the dialog box. I'm using this jquery:

$(document).ready(function() { 
     $('#register').dialog({
         title: 'Register for LifeStor',
         resizable: true,
         autoOpen:false,
         modal: true,
         hide: 'fade',
         width:350,
         height:275,
      });//end dialog   
      $('#reg_link').click (function() {
          open: (function(e) {
             $('#register').load ('register.php');
        });
      }); 
    }); 

和此html:

<div id="register"></div>

在.css文件中设置为显示:无.

which is set to display:none in the .css file.

进一步,在表单内部,链接称为:

Further on, inside a form, the link is called:

<td><font size="2">Not registered? <a href="#" name="reg_link">Sign-Up!</a></td>

(我将表格更改为div).

(I'll be changing the table to divs).

此代码没有任何错误,但是单击链接后没有任何反应.我从其他堆栈溢出帖子中获得了以上大部分内容.我想念什么吗?表格html是否有干扰?

I don't get any errors with this code, but nothing happens when I click the link. I got most of the above from other stack overflow posts. Am I missing something? Is the table html interfering?

关于...

推荐答案

在您的链接中

<a href="#" name="reg_link">Sign-Up!</a>

您有name="reg_link"应该是id="reg_link",即

<a href="#" id="reg_link">Sign-Up!</a>

因此它将与以下代码一起使用

So it'll work with following code

$('#reg_link').click(function(e) {
    e.preventDefault();
    $('#register').load('register.php');
});

要使其成为一个对话框,您可以使用

To make it a dialog you can use

$(document).ready(function() { 

     var dlg=$('#register').dialog({
        title: 'Register for LifeStor',
        resizable: true,
        autoOpen:false,
        modal: true,
        hide: 'fade',
        width:350,
        height:275
     });


     $('#reg_link').click(function(e) {
         e.preventDefault();
         dlg.load('register.php', function(){
             dlg.dialog('open');
         });
      }); 
});

只是一个例子 .

这篇关于在jQuery模式对话框onclick中加载外部php文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆