Objects, Events, This - Customizing the onreadystatechange event 
Author Message
 Objects, Events, This - Customizing the onreadystatechange event

I would like to declare an object which contains an XML document object.

The XML document has an onreadystatechange event that fires when the
readyState of the object changes.  This is all standard according the
the Microsoft DHTML object model.

It appears that when I assign a function to the onreadystatechange
event I lose the ability to invoke the 'this' keyword in reference to
the properties of the DataSet object which I would like to operate on
in my fnTestComplete function.

Specifically = I want to be able to set the dataloaded property of the
DataSet object to true when readyState property of xmlData
equals "complete".

When the code below executes fnTestComplete fires but gives an error:
this.xmlData.readyState is not an object.

I've combed the web for code examples of how to implement events within
an object but have not found any solution.  Any help would be
appreciated - thanks in advance.

My code looks like this:

<XML ID="AC_proj">
</XML>
<script language="JSCRIPT">
var AC_loaded = false;
var AC = new DataSet(AC_proj);

function DataSet(xmlDataObject)
{
 this.xmlData = xmlDataObject;
 this.dataLoaded = false;
 this.xmlData.onreadystatechange = this.fnTestComplete;

Quote:
}

 function fnTestComplete() {
 window.status = this.xmlData.readyState;
 if (this.xmlData.readyState == "complete") this.dataLoaded = true;

Quote:
}

function LoadAC(DataSet) {
frmdisplay.document.body.innerHTML = "";
DataSet.xmlData.async = false;
window.status = DataSet.dataLoaded;
if (DataSet.dataLoaded == false)
DataSet.xmlData.load("../Banking?AllProjects=false&ReportFlag=AC");
display(DataSet.xmlData);}
</script>

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sat, 03 Aug 2002 03:00:00 GMT  
 Objects, Events, This - Customizing the onreadystatechange event
howdy--

If you get rid of the "this" in the line that's causing the error, it should work as designed, BUT
<HTML>
<HEAD>

</HEAD>
<BODY>

<xml id="AC_Proj"></xml>
<script>
var xmlDoc=new ActiveXObject("msxml2.freethreadeddomdocument.2.6");
xmlDoc.async=false;
xmlDoc.onreadystatechange=function(){showReadystatechange(xmlDoc)};
xmlDoc.load("AC_Proj_xmlFile.xml");

function showReadystatechange(obj){
    window.status=obj.readyState;
    if (obj.readyState==4)show(obj);
    };

function show(obj){

    AC_Proj.loadXML(obj.xml);
    alert(AC_Proj.xml);

    };

</script>

</body>
</html>

T

Quote:

> I would like to declare an object which contains an XML document object.

> The XML document has an onreadystatechange event that fires when the
> readyState of the object changes.  This is all standard according the
> the Microsoft DHTML object model.

> It appears that when I assign a function to the onreadystatechange
> event I lose the ability to invoke the 'this' keyword in reference to
> the properties of the DataSet object which I would like to operate on
> in my fnTestComplete function.

> Specifically = I want to be able to set the dataloaded property of the
> DataSet object to true when readyState property of xmlData
> equals "complete".

> When the code below executes fnTestComplete fires but gives an error:
> this.xmlData.readyState is not an object.

> I've combed the web for code examples of how to implement events within
> an object but have not found any solution.  Any help would be
> appreciated - thanks in advance.

> My code looks like this:

> <XML ID="AC_proj">
> </XML>
> <script language="JSCRIPT">
> var AC_loaded = false;
> var AC = new DataSet(AC_proj);

> function DataSet(xmlDataObject)
> {
>  this.xmlData = xmlDataObject;
>  this.dataLoaded = false;
>  this.xmlData.onreadystatechange = this.fnTestComplete;
> }

>  function fnTestComplete() {
>  window.status = this.xmlData.readyState;
>  if (this.xmlData.readyState == "complete") this.dataLoaded = true;
> }

> function LoadAC(DataSet) {
> frmdisplay.document.body.innerHTML = "";
> DataSet.xmlData.async = false;
> window.status = DataSet.dataLoaded;
> if (DataSet.dataLoaded == false)
> DataSet.xmlData.load("../Banking?AllProjects=false&ReportFlag=AC");
> display(DataSet.xmlData);}
> </script>

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 03 Aug 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. onreadystatechange event will not fire for a frame?

2. Does IFRAME fire onreadystatechange event?

3. body onreadystatechange event

4. Catching an IFrame's onreadystatechange event

5. onreadystatechange Event

6. Determining which object fired event from event handler.

7. InternetExplorer.Application object and the event object

8. Referencing document object of IFrame object in event handler

9. fire keyboard events form an onclick page event

10. Call client events from server side events

11. How to Retrieve Events For One Day From An Event Log on Windows 2000/NT

12. Write events to the event log ?

 

 
Powered by phpBB® Forum Software