下面的代码在我的第一个PHP文件上正常运行,但是当我加载另一个文件并使用相同的脚本时,它似乎不起作用,我没有得到alert (idstate);
的警报。 CSS / HTML工作正常。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("li").click(function(){
if (event.target.id!=""){
var idstate=(event.target.id)
alert (idstate);
$.post( "somepage.php", { variable: idstate}, function(data)
{
alert(data);
});
}
});
});
</script>
答案 0 :(得分:0)
当您加载另一个文件时,您必须将其与您的php页面链接。<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
<script src="path/custom.js"></script>