Problem referencing objects in JS
Posted: Sun Sep 17, 2006 4:03 pm
I have some code and it looks like this:
Then the callback function that is in the Weblog object is called.
For some reason when Weblog.GetWeblog() is called, firefox says that the MakeRequest() method is undefined.
I believe that the object reference is not working.
I've looked for examples and stuff all over Google but I can't find anything.
Any help would be greatly appreciated.
request.js wrote:Code: Select all
Request= { http : false, xmldom : false, init : function() { /*somecode*/ }, CreateXmlHttpRequestObject : function() { /*somecode*/ }, CreateXmlDomObject : function () { /*somecode*/ }, MakeRequest : function (method, url, obj) { this.http.open(type, url) if (typeof obj == 'object') { this.http.onstatechange = obj.HandleResponse( this.http.responseText, this.http.ResponseXml); } else { this.http.onstatechange = this.HandleResponse(); } }, HandleResponse : function () { /*somecode for default response handling*/ } }
weblog.js wrote:Code: Select all
var Weblog= { url : 'weblog.php', method : 'GET', frame : 'contentFrame', request : null, init : function (requestObj, frame) { /*somecode*/ if (typeof requestObj == "object") { this.request = requestObj; } }, GetWeblog : function () { this.request.MakeRequest(method, url+'?a=get&v=all', this); }, HandleResponse : function (responseText, ResponseXml) { /*somecode*/ } }
What should be happening is when I call Weblog.GetWeblog(), it calls the MakeRequest() method of my Request object.page.php wrote:Code: Select all
Weblog.init(Request, "contentFrame");
Then the callback function that is in the Weblog object is called.
For some reason when Weblog.GetWeblog() is called, firefox says that the MakeRequest() method is undefined.
I believe that the object reference is not working.
I've looked for examples and stuff all over Google but I can't find anything.
Any help would be greatly appreciated.