Ajax-вызов PHP ничего не возвращает
Я пытаюсь сделать мой первый пример ajax, работающий над моим MAMP. мой ajax.html выглядит так:
<html>
<head>
<script src='ajax.js'></script>
</head>
<body onload = 'ajax()'>
<div id='test'></div>
</body>
</html>
мой ajax.js выглядит так:
function ajax() { >>var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","http://localhost:8888/ajax.php",true); xmlhttp.send(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("test").innerHTML=xmlhttp.responseText; } } }
мой ajax.php выглядит так:
эхо "привет мир";
Я обнаружил заголовок ответа от firebug:
Заголовки ответа
Keep-Alive соединения
Контент-длина 11
Content-Type text / html
Дата Пн, 05 Ноя 2012 18:57:46 GMT
Keep-Alive timeout = 5, max = 99
Сервер Apache / 2.2.22 (Unix) mod_ssl / 2.2.22 OpenSSL / 0.9.8r DAV / 2 PHP / 5.4.4
X-Pad избежать ошибки браузера
X-Powered-By PHP / 5.4.4
но ничего в тексте ответа и ничего не изменилось в моем HTML.
Кто-нибудь может мне помочь, пожалуйста?
Спасибо!