ooostephen (2) [Avatar] Offline
#1
anyone still out there?

the code from the book p.74 is fundamentally different than the downloaded sample code, and i can't get the books example to work. if anyone can explain why its failing, please do. from the code below, i'd expect an alert reading 'loadXmlDoc' to appear.

var ajaxReq = new Object();
ajaxReq.READY_STATE_UNINITIALIZED = 0;
ajaxReq.READY_STATE_LOADING = 1;
ajaxReq.READY_STATE_LOADED = 2;
ajaxReq.READY_STATE_INTERACTIVE = 3;
ajaxReq.READY_STATE_COMPLETE = 4;

ajaxReq.ContentLoader = function(url, req, onLoad, onError)
{
this.url = url;
this.req = req;
this.onLoad = onLoad;
this.onError = onError;
this.loadXmlDoc();
}

ajaxReq.ContentLoader.prototype.loadXmlDoc = function()
{
alert('loadXmlDoc');
}//end ContnetLoader.prototype obj




window.onload = function()
{
var myAjax = ajaxReq;
myAjax.ContentLoader('my url', null, null, null);
}

*the above is from the book, and it creates a new object. the sample file doesn't use objects. it uses prototype to add member functions.
ooostephen (2) [Avatar] Offline
#2
Re: chpt 3, contentLoader book example diff than code sample....
after hiring a 'livePerson' coding professional to explain this example, it seems the code is fundamentally flawed; it will not work. the reason seems to be that you can not add JSON object to a function, which is itself a prototyped property of an object.