我試圖實現 - 當我點擊鏈接電影的名稱,getSummary函數被調用,iframe.php數據在總結格所示。以下代碼有效,但存在問題。在彙總 div腳本(如在這種情況下的日期選擇器)將無法正常工作(但他們仍然工作在div中,而不是通過ajax)。我做錯了什麼?謝謝參觀!AJAX - 腳本不工作
的index.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>