[英]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.
分析您的脚本,看看您的data ...属性正在发生什么。
As far as I can see, you should add a new attribute to your a tag, something similar to data-variable="value". 据我所知,您应该在标签中添加一个新属性,类似于data-variable =“ value”。
A small snippet of code for this using jQuery, would be the following 以下是使用jQuery的一小段代码,如下所示
The HTML: HTML:
<div>
<a href="#" class="big-link" data-reveal-id="myModal" data-variable="variable value " data-animation="fade">Click me</a>
</div>
The CSS: CSS:
a { display: inline-block; padding: 10px; color: #333; text-decoration: none; border: 1px solid #333; }
The JavaScript: 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/ . 您可以在http://jsfiddle.net/上尝试此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.