Welcome to Dream.In.Code
Become an Expert!

Join 149,747 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,416 people online right now. Registration is fast and FREE... Join Now!




Basic AJAX problem

 
Reply to this topicStart new topic

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

MBraybrook
12 Feb, 2007 - 04:46 PM
Post #1

New D.I.C Head
*

Joined: 14 Aug, 2006
Posts: 17


My Contributions
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.asp

First 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
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Basic AJAX Problem
15 Feb, 2007 - 12:37 PM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,294



Thanked: 18 times
Dream Kudos: 725
My Contributions
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.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 05:38AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month