如何从jquery iframe发送值并在php文件中获取。我有一个名为index.php的文件,并且在单击按钮(deposit_summary)时触发了下面的jquery,问题是在products.php中没有获取bean_id
$bean_id='123asd';
?>
<script>
$('#deposit_summary').click( function(){
var pagetitle = "Create new Project Rate Product";
var dialog = $('<div id=\"dialog_box\" style=\"overflow: hidden;\"></div>')
.html('<iframe width= \"100%\" height= \"100%\" style=\"border: 0px;\" src=\"products.php?bean_id=".$bean_id."\"></iframe>')
.dialog({
autoOpen: false,
modal: true,
height: 320,
width: 500,
title: pagetitle
});
dialog.dialog('open');
});
});
</script>
in product.php
$id=$_GET['bean_id'];
答案 0 :(得分:0)
var simple = '<?php echo $bean_id; ?>';
$('#deposit_summary').click( function(){
var pagetitle = "Create new Project Rate Product";
var dialog = $('<div id=\"dialog_box\" style=\"overflow: hidden;\"></div>')
.html('<iframe width= \"100%\" height= \"100%\" style=\"border: 0px;\" src=\"products.php?bean_id='+simple+'\"></iframe>')
.dialog({
autoOpen: false,
modal: true,
height: 320,
width: 500,
title: pagetitle
});
dialog.dialog('open');
});
});
答案 1 :(得分:0)
将您的变量放在<script>
标记
var simple = '<?php echo $bean_id; ?>';
$('#deposit_summary').click( function() {
var pagetitle = "Create new Project Rate Product";
var dialog = $('<div id=\"dialog_box\" style=\"overflow: hidden;\"></div>').html('<iframe width= \"100%\" height= \"100%\" style=\"border: 0px;\" src=\"products.php?bean_id='+simple+'\"></iframe>').dialog({
autoOpen: false,
modal: true,
height: 320,
width: 500,
title: pagetitle
});
dialog.dialog('open');
});
答案 2 :(得分:0)
您可以通过url传递多个参数,方法是将它们与&amp ;.分开。
// multiple parameters
var simple = '<?php echo $bean_id; ?>';
var param_1 = '<?php echo $param_1; ?>';
var param_2 = '<?php echo $param_2; ?>';
$('#deposit_summary').click( function(){
var pagetitle = "Create new Project Rate Product";
var dialog = $('<div id=\"dialog_box\" style=\"overflow: hidden;\"></div>')
.html('<iframe width= \"100%\" height= \"100%\" style=\"border: 0px;\" src=\"products.php?bean_id='+simple+'¶m1='+param_1+'¶m1='+param_2+'\"></iframe>')
.dialog({
autoOpen: false,
modal: true,
height: 320,
width: 500,
title: pagetitle
});
dialog.dialog('open');
});
});
在他们的php文件中
$id=$_GET['bean_id'];
$param1 = $_GET['param1'];
$param2 = $_GET['param2'];