简体   繁体   中英

how to send and receive a variable from php to popup using jquery on same page without load the page

如何使用jQuery从PHP接收数据到弹出菜单?

<a href="#?da=<?php echo $fetch['da_ref'] ?>" class="big-link" data-reveal-id="myModal" data-animation="fade" style="text-decoration: none"><?php echo $fetch['da_ref'];?></a>

Perhaps you can use the method of retrieving the variable's value within your pop-up the same way you do with the attributes from your a tag. Analyse your script and see what is happening with your data-... attributes.

As far as I can see, you should add a new attribute to your a tag, something similar to data-variable="value".

A small snippet of code for this using jQuery, would be the following

The HTML:

<div>
    <a href="#" class="big-link" data-reveal-id="myModal" data-variable="variable value " data-animation="fade">Click me</a>
</div>

The CSS:

a { display: inline-block; padding: 10px; color: #333; text-decoration: none; border: 1px solid #333; }

The JavaScript:

$(document).ready(function() {
    $(".big-link").on("click", function() {
        var variable = $(this).attr("data-variable");
        $(this).parent().append(variable);
    });
});

You can try this on http://jsfiddle.net/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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