我正在尝试实现 - 当我单击链接 Name of movie时,调用 getSummary 函数并且 iframe.php 数据显示在摘要div 中。下面的代码有效,但是,有一个问题。摘要div中的脚本(如本例中的 datepicker)将不起作用(但是它们仍然在不是通过 ajax 制作的 div 中工作)。我做错了什么?谢谢参观!
索引.php:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
... other scripts ...
<script type="text/javascript">
function getSummary(id)
{
$.ajax({
type: "GET",
url: 'include/iframe.php',
data: "id=" + id, // appears as $_GET['id'] @ ur backend side
success: function(data) {
// data is ur summary
$('#summary').html(data);
}
});
}
</script>
</head>
<body>
<a href="javascript:void(0);" class="movie" onclick="getSummary(2)">Name of movie</a <br/>
<div id="summary">Here is summary of movie</div>
</body>
</html>
包括/iframe.php:
<form class="form-horizontal">
<fieldset>
<div class="input-prepend">
<span class="add-on"><i class="icon-calendar"></i></span><input type="text" name="range" id="range" />
</div>
</fieldset>
</form>