我試圖從名爲「include.php」的php文件中加載內容到另一個名爲「index.php」的php文件中。但加載不起作用。代碼如下:php/Javascript/Ajax加載內容不起作用
文件:index.php文件
<header>
<script type="text/javascript">
function load(){
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
}else{
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechage = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
document.getElementById(adiv).innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open('GET', 'include.php', true);
xmlhttp.send();
}
</script>
</head>
<body>
<input type="submit" value="Submit" onclick="load();">
<div id="adiv"></div>
</body>
文件:include.php
<?php
echo 'Hello!';
?>
感謝。
轉到檢查元素 - >網絡選項卡 - >你能在那裏看到什麼? –
我有三個文件的列表:「index.php」,「style.css」和「include.inc.php」。所有這三個文件的方法是「GET」。 「index.php」和「include.inc.php」的狀態是「OK」。 「style.css」的狀態是「未修改」。 – Sara