简体   繁体   English

jQuery对话框-将变量值从PHP传递到jQuery函数

[英]jQuery Dialog Box - Passing variable value from PHP to jQuery function

Need someone to help me on the jQuery Dialog plugin by Eric Martin - Simple Model 需要有人在Eric Martin的jQuery Dialog插件我提供帮助-Simple Model

I have a PHP page that contains the link that I want to pass a value to another page. 我有一个PHP页面,其中包含要将值传递给另一个页面的链接。 Thus, I need help on how to pass the value to the jQuery script that contain the var for the page URL below? 因此,我需要有关如何将值传递到包含以下页面URL的var的jQuery脚本的帮助吗?

Profile.php Profile.php

<div id='basic-modal'>
       <a href='#' class='basic'>Jquery Dialog Demo</a>
</div>

Note: When I click on the link, it will call the jQuery basic-model div from Basic.js 注意:当我单击链接时,它将从Basic.js调用jQuery基本模型div

Basic.js Basic.js

jQuery(function ($) {

    // Load dialog on click
    $('#basic-modal .basic').click(function (e) {

    // Display an external page using an iframe
var src = "http://365.ericmmartin.com/";
$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
    closeHTML:"",
    containerCss:{
        backgroundColor:"#fff",
        borderColor:"#fff",
        height:450,
        padding:0,
        width:830
    },
    overlayClose:true
});

        return false;
    });
});

Note: On the above, I want the var src contain variable value that I should pass it from the Profile.php instead. 注意:在上面,我希望var src包含变量值,而应该从Profile.php传递它。 How should I do this? 我应该怎么做?

Change Profile.php slightly: 稍微更改Profile.php:

<div id='basic-modal'>
       <a href='http://localhost/Poll.php?id=1&validate=yes' class='basic'>Jquery Dialog Demo</a>
</div>

Change Basic.js like so: 像这样更改Basic.js:

    jQuery(function ($) {

        // Load dialog on click
        $('#basic-modal .basic').click(function (e) {
        e.preventDefault();

        // Display an external page using an iframe
        var src = $(this).attr('href');
        $.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
            closeHTML:"",
            containerCss:{
                backgroundColor:"#fff",
                borderColor:"#fff",
                height:450,
                padding:0,
                width:830
            },
            overlayClose:true
        });


            return false; // not sure why you're doing this
        }); // end of click handler




    });  // end of document.ready
e.preventDefault();
var src = $(e.target).attr("href");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM