Simple PHP, AJAX request

KasynaElugh

New Member
Right now I'm struggling to get this simple PHP AJAX request to work.\[code\]<html> <head> <script type="text/javascript"> function getSuggestions(type){ if(type == "") { document.getElementById("entries").innerHTML="test" return; } 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) { document.getElementById("entries").innerHTML=xmlHttp.response; } } xmlHttp.open("GET","getData.php?status="+type,true); xmlHttp.send(); } </script> </head> <body> <div id="A" onclick='getSuggestions("A")'>Click for A</div> <div id="P" onclick='getSuggestions("P")'>Click for P</div> <div id="R" onclick='getSuggestions("R")'>Click for R</div> <div id="entries"></div> </body> </html>\[/code\]Below is getData.php\[code\]<?php $status = $_GET["status"]; echo $status;?>\[/code\]Everytime I click on any of the tags I get "undefined" in the "entries" tag. Could anybody explain why it's undefined?
 
Back
Top