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

查看:18
本文介绍了在 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 文件中设置为 display:none.

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" 代替,即

you have name="reg_link" that should be id="reg_link" instead, i.e.

<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天全站免登陆