Código:
Código PHP:<html> <head> <title>Sample</title> <script type="text/javascript"> //Funciones AJAX function creaAjax(){ var req; if(window.XMLHttpRequest){ //For Firefox, Safari, Opera req = new XMLHttpRequest(); } else if(window.ActiveXObject){ //For IE 5 req = new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.ActiveXObject){ //For IE 6+ req = new ActiveXObject("Msxml2.XMLHTTP"); } else { //Error for an old browser alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera'); return null; } return req; } function enviar_consulta(url,capa,valores) { var ajax=creaAjax(); var capaContenedora = document.getElementById(capa); ajax.onreadystatechange = function () { if(ajax.readyState==4) { capaContenedora.innerHTML=ajax.responseText; } }; ajax.open ('GET', url, true); ajax.send(null); return; } </script> </head> <body> <div id="prueba" style="height: 400px; width: 600px;"></div> <script> enviar_consulta("h t t p : / / 1 2 7 . 0 . 0 . 1 / servidor.php","prueba","");</script> </body> </html>
Código PHP:
<?php
echo "hola";
?>