Ciao a tutti.
Non riesco a far funzionare il classico "please wait" con ajax + php.
Non capisco perchè il "please wait" non si mantiene per il tempo che ho previsto in go_to_sleep.php.
Ecco i codici, questa è la pagina index.htm:
go_to_sleep.php:codice:<html> <head> <script type="text/javascript"> var xml_http_obj = false; if (window.XMLHttpRequest){ //Firefox, safari etc xml_http_obj = new XMLHttpRequest(); }else if(window.ActiveXObject){ //Microsoft IE xml_http_obj = new ActiveXObject("Microsoft.XMLHTTP"); } function get_data(url,wait_div_id){ if (xml_http_obj){ xml_http_obj.open("GET",url,true); xml_http_obj.onreadystatechange = function(){ if (xml_http_obj.readyState == 4 && xml_http_obj.status == 200){ document.getElementById(wait_div_id).style.visibility="hidden"; }else{ document.getElementById(wait_div_id).style.visibility="visible"; } } xml_http_obj.send(null); } } </script> <style> div#wait{ background-color:white; position:absolute; top:240px; left:360px; width:400px; height:50px; visibility:hidden; border: 0px; padding:0px; } </style> </script> </head> <body id="body"> <H1>Please Wait AJAX </H1> <form action="http://www.yahoo.com" method="post" onSubmit="get_data('go_to_sleep.php','wait')"> <div id="wait" > [img]wait.gif[/img]Please wait ... </div> <input type="submit" value="Search"> </form> </body> </html>
Che sbaglio?codice:<?php sleep(5);?>
Grazie

Rispondi quotando
