01hanstu Posted November 11, 2008 Share Posted November 11, 2008 Hi, i have a form that takes its time to process, so i would like to know if there is any way of having some text printed saying something like "Please be patient . . ." once the button has been clicked just so the user knows its working . Please Advise John Pickering Quote Link to comment Share on other sites More sharing options...
Maq Posted November 11, 2008 Share Posted November 11, 2008 Yes there is a way. The best way to do this is with AJAX. Quote Link to comment Share on other sites More sharing options...
01hanstu Posted November 12, 2008 Author Share Posted November 12, 2008 Hi, thanks for the reply, With AJAX, will it interfere with my script? Quote Link to comment Share on other sites More sharing options...
Maq Posted November 12, 2008 Share Posted November 12, 2008 Hi, thanks for the reply, With AJAX, will it interfere with my script? Considering I haven't seen your script, nor do I know what it does, it's impossible to say. The probable answer is no, but if you could post your code and explain what it does I, or someone else, may be able to give you a definite answer. Quote Link to comment Share on other sites More sharing options...
cersos Posted November 12, 2008 Share Posted November 12, 2008 You don't really need AJAX to do this. You can do it with the appropriate javascript and style tags. Consider something like this (the flush is key here): <?php ?> <html> <head> <script language=JavaScript> function pleaseWait() { if (document.getElementById) document.getElementById('pleaseWait').style.visibility = 'hidden'; else if (document.layers) document.pleaseWait.visibility = 'hidden'; else document.all.pleaseWait.style.visibility = 'hidden'; } </script> </head> <body onLoad=pleaseWait()> <span id=pleaseWait style="position:absolute;left:0;top:0;background-color:white;layer-background-color:white;height:100%;width:100%;"> This might take a while, Please wait... </span> <? flush(); sleep(10); print "<br>Done sleeping<br>\n"; ?> </body> </html> Unless I misunderstood and you want to have your AJAX code generate a 'working' message while it is processing. In that case, you'll want to check out xmlHttp.readyState and add a catch for it in your AJAX function. Something like: function ajax(target,value,handler) { var xmlHttp; try { xmlHttp=new XMLHttpRequest(); } catch (e) { 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; } } } xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3) document.getElementById(target).innerHTML = 'Working, please wait...'; else if(xmlHttp.readyState == 4) document.getElementById(target).innerHTML = xmlHttp.responseText; } xmlHttp.open('GET',handler+'?q='+value,true); xmlHttp.send(null); } Steve Quote Link to comment Share on other sites More sharing options...
01hanstu Posted November 13, 2008 Author Share Posted November 13, 2008 Hi, thanks for your help, i have it sorted now, you have all been a great help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.