【发布时间】:2014-08-11 00:17:52
【问题描述】:
我有一个问题,我无法将任何参数传递给模式窗口(使用 Bootstrap 3),我尝试使用此链接中所述的解决方案,但无法使其工作:
Dynamically load information to Twitter Bootstrap modal
(解决方案kexxcream用户)。
但是按下按钮,显示屏什么也没有显示,显然是块,下面附上一张图片:
http://i.imgur.com/uzRUyf1.png
我已附上代码(左上方相同的代码帖子);
HTML 代码:
<div id="myModal" class="modal hide fade">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h3>Title</h3>
</div>
<div class="modal-body">
<div id="modalContent" style="display:none;">
</div>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-info" data-dismiss="modal" >Close</a>
</div>
</div>
JS代码:
$("a[data-toggle=modal]").click(function()
{
var essay_id = $(this).attr('id');
$.ajax({
cache: false,
type: 'POST',
url: 'backend.php',
data: 'EID='+essay_id,
success: function(data)
{
$('#myModal').show();
$('#modalContent').show().html(data);
}
});
});
按钮:
<a href='#myModal' data-toggle='modal' id='2'> Edit </a>
PHP 代码(backend.php):
<?php
$editId = $_POST['EID'];
?>
<div class="jumbotron">
<div class="container">
<h1>The ID Selected is <?php echo $editId ?></h1>
</div>
</div>
【问题讨论】:
-
$editId = filter_var($_POST["id"], FILTER_SANITIZE_NUMBER_INT); // 只是玩安全:)
标签: jquery html twitter-bootstrap modal-dialog window