The following is essentially my first attempt programming using the AJAX methodology, though not my first attempt programming with ASP or javascript. I'll start by simply posting the various parts of the code, then explain a little more about the specific help i'd like. The online sample is available at
www.mbraybrook.co.uk:40/ajax/myajax/index.aspFirst the basic html content:
CODE
.
.
.
<script src="includes/AJAX.js"></script>
.
.
.
<div id="copy">
<h1>AJAX ASP Testing Site</h1>
<div id="Foo"></div>
<p> <a href="java script:sndReq('Foo')">[foo]</a> <a href="java script:sndReq('None')">[none]</a> </p>
</div>
Now the javascript i am using:
CODE
// JavaScript Document
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', 'includes/ajax.cfm?action='+action);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
var update = new Array();
if(response.indexOf('|' != -1)) {
//debug line
response.writeln("update=")
update = response.split('|');
//debug line
document.writeln("Update[0]="+update[0])
//Cannot perform "getElementByID"
//document.getElementById(update[0]).innerHTML = update[1];
}
}
}
I obtained the bulk of this from an external source and while i understand what it is trying to do, apparently i dont know enough to debug it. I think the error occurs when i attempt to either create or split the "update" variable.
This is the asp page that is called:
CODE
<%
Dim passedAction
passedAction = Request.QueryString("action")
Select Case passedAction
Case passedAction = "None"
Response.Write("Foo|none done")
Case passedAction = "Foo"
Response.Write("Foo|foo Done")
End Select
%>
Thanks in advance for any and all assistance