B
Bill H
I am new to this newsgroup, so if I step on any established
conventions or rules, please bear with me.
I am attempting to use AJAX as a way of informing a visitor that
things are happening so they dont hit their back button, or click
submit again etc. What I want to be able to do is give them a running
status. Something like this:
Saving your data.... done
Updating your profile... done
Creating your pdf... done
Operation complete.
Where the "done" shows up when a particular event has happened on the
server. I have already created the perl routines that send a simple
"ID|STATUS" as it goes along but the problem is it doesnt show
anything till it is all done. Here is a simple html program I am using
to test it.
<HEAD>
</HEAD>
<BODY>
Hello <a href="javascript:sndReq('foo')">click me</a></P>
<script language="javascript">
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sndReq(action) {
http.open('get', 'project.pl?action='+action);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
document.HERE.THIS.value += response;
}
}
</script>
<P>
<FORM NAME="HERE">
<TEXTAREA NAME="THIS" COLS="60" ROWS="6"></TEXTAREA>
</FORM>
</body>
</html>
The program project.pl right now is sending a new status every 2
seconds for this test purpose (and it is doing every 2 seconds when I
test the program directly in the browser).
I hope I am making sense with this.
Bill H
conventions or rules, please bear with me.
I am attempting to use AJAX as a way of informing a visitor that
things are happening so they dont hit their back button, or click
submit again etc. What I want to be able to do is give them a running
status. Something like this:
Saving your data.... done
Updating your profile... done
Creating your pdf... done
Operation complete.
Where the "done" shows up when a particular event has happened on the
server. I have already created the perl routines that send a simple
"ID|STATUS" as it goes along but the problem is it doesnt show
anything till it is all done. Here is a simple html program I am using
to test it.
<HEAD>
</HEAD>
<BODY>
Hello <a href="javascript:sndReq('foo')">click me</a></P>
<script language="javascript">
function createRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var http = createRequestObject();
function sndReq(action) {
http.open('get', 'project.pl?action='+action);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
document.HERE.THIS.value += response;
}
}
</script>
<P>
<FORM NAME="HERE">
<TEXTAREA NAME="THIS" COLS="60" ROWS="6"></TEXTAREA>
</FORM>
</body>
</html>
The program project.pl right now is sending a new status every 2
seconds for this test purpose (and it is doing every 2 seconds when I
test the program directly in the browser).
I hope I am making sense with this.
Bill H