RIRedinPA Posted October 29, 2008 Share Posted October 29, 2008 I'm not getting any returned values from my php page. Not sure what I am doing wrong here. I'm basically repurposing code that is working. Javascript: var xmlHttp = checkajax(); xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { var returneditem = xmlHttp.responseText; alert(returneditem); } } xmlHttp.open("GET","editissue.php?", true); xmlHttp.send(null); PHP (editissue.php) <?php echo "what the heck?"; ?> The Javascript alert displays no value. Like I said, I am using the same exact code in other areas to return a lot of php code so I'm at a loss as to explain why it is not working here. Any help would be mucho appreciated. checkajax function function checkajax() { //ajax compatibility check var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } return xmlHttp } Link to comment https://forums.phpfreaks.com/topic/130609-xmlhttpresponsetext-has-no-value/ Share on other sites More sharing options...
RIRedinPA Posted October 29, 2008 Author Share Posted October 29, 2008 grrr.... same code, pulled out and dumped into a test page works fine: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>AJAX Test</title> <script language="javascript"> function ajaxtest() { var xmlHttp = checkajax(); xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { var returneditem = xmlHttp.responseText; document.getElementById('msg').innerHTML = returneditem } } xmlHttp.open("GET","editissue.php?", true); xmlHttp.send(null); } function checkajax() { //ajax compatibility check var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } return xmlHttp } </script> </head> <body> <div id="button" style="background-color: #CC6600; color: #fff; width: 300px; height: 30px; text-align: center; padding: 3px;"><a href="javascript:void(0)" onmousedown="ajaxtest()" style="text-decoration: none; color: #660033; letter-spacing: .6em; ">Click</a></div> <div id="msg" style="position: absolute; top: 200px; left: 200px; background-color: #FFCC33; color: #333; width: 400px; height: 400px; text-align: center; vertical-align: middle; border: 1px solid #FF6600; "> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/130609-xmlhttpresponsetext-has-no-value/#findComment-677660 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.