...

View Full Version : Javascript Objects problem, very confused.



sythem
09-10-2008, 03:44 AM
So, I have a javascript object that inherits from the XMLHttpRequest() object. The problem is, it seems it can access two of the required functions, but not the last one. Any help would be much appreciated.



function start() {
display('Start<br>', false, 'content');
handlerxml('head', false, 'header.php');
}

function handlerxml(ID, setapp, page) {
this.prototype = new GetXmlHttpObject();
this.outID = ID;
display('Calldiv 1<br>', true, 'content');
this.app = setapp;
display('Calldiv 2<br>', true, 'content');
var url=page;
display('Calldiv 3<br>', true, 'content');
try {
this.onreadystatechange=stateChanged;
display('Calldiv 4<br>', true, 'content');
}
catch(err) {
display( err + '<br>', true, 'content');
}
try {
this.open("GET",url,true);
display('Calldiv 5<br>', true, 'content');
}
catch(err) {
display( err + '<br>', true, 'content');
}
try {
this.send(null);
display('Calldiv 6<br>', true, 'content');
}
catch(err) {
display( err + '<br>', true, 'content');
}
}

function stateChanged() {
if (this.readyState==4)
{
display(this.responseText, this.app, this.outID);
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp
}


This is the output
Start
Calldiv 1
Calldiv 2
Calldiv 3
Calldiv 4
Calldiv 5
TypeError: Object [object global] has no method 'send''



Also, to clarify why I need this in object form seeing as how the original code works flawlessly, I have to be able to change the contents of multiple divs at a time, which it just kinda fails at unless you have more than one object doing it.

liorean
09-10-2008, 05:04 AM
You are calling handlerxml as a normal function call. That means that this will be the global object, i.e. window. Understanding that, your problem should be glaringly obvious.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum