Basic AJAX problem

My first attempt at AJAX and i've got stuck with some trouble shoo

Page 1 of 1

1 Replies - 2134 Views - Last Post: 15 February 2007 - 01:37 PM Rate Topic: -----

#1 MBraybrook   User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 37
  • Joined: 14-August 06

Basic AJAX problem

Posted 12 February 2007 - 05:46 PM

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

First the basic html content:
<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>

Now the javascript i am using:
// Javascript Document
function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
		ro = new XMLHttpRequest();
	return ro;

var http = createRequestObject();

function sndReq(action) {'get', 'includes/ajax.cfm?action='+action);
	http.onreadystatechange = handleResponse;

function handleResponse() {
	if(http.readyState == 4){
		var response = http.responseText;
		var update = new Array();
		if(response.indexOf('|' != -1)) {

//debug line

			update = response.split('|');

//debug line
			//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:
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

Is This A Good Question/Topic? 0
  • +

Replies To: Basic AJAX problem

#2 girasquid   User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: Basic AJAX problem

Posted 15 February 2007 - 01:37 PM

What exactly is going wrong? Can you post whatever errors you're receiving?
Also, you might need to take the space out of the word "java script" inside your <a> tags.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1