這裏是我的Ajax代碼:AJAX和PHP未定義指數
function send()
{
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.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert(xmlhttp.responseText);
}
}
xmlhttp.open("POST","test.php",true);
xmlhttp.send('subject=' + document.getElementById("subject").value);
}
這裏是我的PHP代碼:
<?php
$subject = $_POST['subject'];
echo $subject;
?>
它說,在PHP代碼,不確定的指標線2的錯誤。 我不知道還有什麼可以做..所有的幫助將被附加,謝謝。
一個明顯的評論,但你的表單元素肯定有id'subject'?我也會嘗試用'GET'來代替,值得一試! – martincarlin87