|
Answer» I Have some code here that displays a .php file on my html page.
<script type="text/javascript"> var page = "ajaxpanel.php"; function ajax(url,target) { // native XMLHttpRequest object if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.onreadystatechange = function() {ajaxDone(target);}; req.open("GET", url, true); req.send(null); // IE/Windows ActiveX version } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = function() {ajaxDone(target);}; req.open("GET", url, true); req.send(); } } SETTIMEOUT("ajax('"+url+"','"+target+"')", 10000); //setTimeout("ajax('ajaxpanel.php','ajaxlist')", 10000); } function ajaxDone(target) { if (req.readyState == 4) { document.getElementById(target).INNERHTML = req.responseText; } } ajax('ajaxpanel.php','ajaxlist'); </script> The Code will now show the php file where am I going wrong?dont you NEED to put the tagat the end so your peice of code looks like this
Code: [Select]<?php <script type="text/javascript"> var page = "ajaxpanel.php"; function ajax(url,target) { // native XMLHttpRequest object if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.onreadystatechange = function() {ajaxDone(target);}; req.open("GET", url, true); req.send(null); // IE/Windows ActiveX version } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = function() {ajaxDone(target);}; req.open("GET", url, true); req.send(); } } setTimeout("ajax('"+url+"','"+target+"')", 10000); //setTimeout("ajax('ajaxpanel.php','ajaxlist')", 10000); } function ajaxDone(target) { if (req.readyState == 4) { document.getElementById(target).innerHTML = req.responseText; } } ajax('ajaxpanel.php','ajaxlist'); </script> ?>It Is HTML not PHP.Can I ask... Why use AJAX?
Why not use a funtion to CALL the info from the file?
|