제출 버튼이 있습니다. 그것을 클릭하면, 나는 PHP 콜백 파일에서 응답을 반환하려고 노력하고 있습니다. 그러나 나는 어떤 반응도 얻지 못하고있다. 제출을 클릭, 나는 아마도 실수 무엇 PHP의 new.php
AJAX 양식이 PHP 콜백과 상호 작용하지 않습니다.
<script language="javascript" type="text/javascript">
function callme()
{
var req;
try
{
req = new XMLHttpRequest();
}catch (e)
{
try
{
req = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e)
{
try
{
req = new ActiveXObject("Microsoft.XMLHTTP");
}catch (e)
{
alert("Your browser broke!");
return false;
}
}
}
req.onreadystatechange=function(){
if(req.readyState==4)
{
document.getElementById("display_area").innerHTML=req.responseText;;
}
}
req.open("GET","phpcall.php",true);
req.send();
}
</script>
로 파일을 명하고, PHP 호출이 다시 파일 - phpcall.php
<?php
echo "returning from phpcall.php";
?>
라는 이름으로
http://localhost/folder/new.php?submit=Submit+Query
다음 URL을 얻을 이리??
<form name='myForm'>
Max Age: <input type='text' id='age' /> <br />
Max WPM: <input type='text' id='wpm' />
<br />
Sex: <select id='sex'>
<option value="m">m</option>
<option value="f">f</option>
</select>
<input type='button' onclick='ajaxFunction()'
value='Query MySQL'/>
</form>
<div id='ajaxDiv'>Your result will display here</div>
감사합니다. 이제는 괜찮습니다 ... – Mayur
'입력 유형 ='버튼 'onclick ='ajaxFunction() '값 ='쿼리 유형 '='버튼 '이어야합니다 onclick = document.getElementById ("ajaxDiv"). innerHTML = req.responseText; 'callme()'value = 'Query MySQL'/> ; ' –