假設我有一個名爲index.php的頁面,它包含一個div元素名稱divContent,其中包含名爲「msg」的按鈕和另一個名爲「show」的按鈕。加載到div後Jquery Ajax錯誤
當我加載index.php兩個按鈕顯示良好。我在我的頁面上添加了jquery。當點擊我的「味精」按鈕時,它會顯示「成功」味精
alert(「successful」);
。它的工作就像當我點擊顯示按鈕(divContent外)時,它會通過ajax技術將另一個頁面內容加載到我的divContent中。
$('#msg').click(function(e) {
alert("successful");
});
} //Whilst editing formatting - extra closing brace
$('#show').click(function(e) {
$.ajax({
type: "GET",
url: "test.php",
success: function(msg){
$('#divContent').html(msg);
}
});
e.preventDefault();
});
test.php
--------
<input type="button" id="msg" />
test.php包含一個與msg按鈕相同的按鈕,它存在於index.php中。我的概率是加載index.php時,點擊msg按鈕它顯示成功的味精,但點擊顯示按鈕時,它加載test.php的包含到divContent中,並點擊msg按鈕,它不顯示「成功」的消息。什麼是問題
是否顯示IE開發者工具中的「控制檯」中的任何錯誤? – 2012-07-18 10:17:17