Linuxマシンでphpを使用しています。私の html コードは、ローカル Apache サーバー ( http://localhost ) にajax 要求を発行し、サーバーからのデータが画面に出力されるはずです。ただし、何も印刷されません。
「クライアント」側のコード (ブラウザーにロードする html ファイル) は次のとおりです。
<html>
<body>
<script language="javascript" type="text/javascript">
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if( ajaxRequest.readyState == 4 ){
document.writeln( ajaxRequest.responseText );
}
}
ajaxRequest.open("GET", "http://localhost/s.php", true);
ajaxRequest.send(null);
}
</script>
</body>
</html>
「サーバー」スクリプト (/var/www/s.php) は次のとおりです。
<html>
<body>
<?php
echo date("H:i:s");
?>
</body>
</html>
助言がありますか?
ティア