假设我有一个名为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