Discussion:
MochiKit.Async.doXHR
Akari no ryu
2008-10-02 05:41:37 UTC
Permalink
I've been battling with this for a few hours now, been reading the
docs and read this groups mails on defferred.callback
None of that seems to help.
My code does the following:

this.interfaceTypes = {
'lines':false,
'regions':false,
'points':false
};
for(var i in this.interfaceTypes)
{
var url = i+'.php';
var queryString = MochiKit.Base.queryString({'do':'fetchTypes'});
log('created url of '+url+' and queryString of '+queryString);
try
{
var request = MochiKit.Async.doXHR(url);
request.addCallBacks(
partial(this.typeLoaded, i),
partial(this.typeFailed, i)
);
}
catch(e)
{
for(var j in request)
{
log('request.'+j+"\n"+request.j)
}
}
}

For all values of request's properties, it's showing up as undefined.

Also, if I don't litter my constructor with log calls, the log calls
don't happen in there and a log call after it won't happen either.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to mochikit+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---
Bob Ippolito
2008-10-02 14:57:47 UTC
Permalink
It looks like your problem is that your usage of partial probably
doesn't do what you intend it to.

request.addCallBacks(
partial(this.typeLoaded, i),
partial(this.typeFailed, i)
);

With that expression, you lose the binding to "this" (since JavaScript
has no bound methods).

You probably want to use bind or method instead of partial in such a
way that you can keep the "this" binding.

-bob
Post by Akari no ryu
I've been battling with this for a few hours now, been reading the
docs and read this groups mails on defferred.callback
None of that seems to help.
this.interfaceTypes = {
'lines':false,
'regions':false,
'points':false
};
for(var i in this.interfaceTypes)
{
var url = i+'.php';
var queryString = MochiKit.Base.queryString({'do':'fetchTypes'});
log('created url of '+url+' and queryString of '+queryString);
try
{
var request = MochiKit.Async.doXHR(url);
request.addCallBacks(
partial(this.typeLoaded, i),
partial(this.typeFailed, i)
);
}
catch(e)
{
for(var j in request)
{
log('request.'+j+"\n"+request.j)
}
}
}
For all values of request's properties, it's showing up as undefined.
Also, if I don't litter my constructor with log calls, the log calls
don't happen in there and a log call after it won't happen either.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to mochikit+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---
Eamonn Kearns
2008-10-03 12:35:32 UTC
Permalink
I'm afraid the problem was even more embarrassing than that.
request.addCallbacks is a method
request.addCallBacks is not.
Stupid dyslexia.
Post by Bob Ippolito
It looks like your problem is that your usage of partial probably
doesn't do what you intend it to.
request.addCallBacks(
partial(this.typeLoaded, i),
partial(this.typeFailed, i)
);
With that expression, you lose the binding to "this" (since JavaScript
has no bound methods).
You probably want to use bind or method instead of partial in such a
way that you can keep the "this" binding.
-bob
Post by Akari no ryu
I've been battling with this for a few hours now, been reading the
docs and read this groups mails on defferred.callback
None of that seems to help.
this.interfaceTypes = {
'lines':false,
'regions':false,
'points':false
};
for(var i in this.interfaceTypes)
{
var url = i+'.php';
var queryString = MochiKit.Base.queryString({'do':'fetchTypes'});
log('created url of '+url+' and queryString of '+queryString);
try
{
var request = MochiKit.Async.doXHR(url);
request.addCallBacks(
partial(this.typeLoaded, i),
partial(this.typeFailed, i)
);
}
catch(e)
{
for(var j in request)
{
log('request.'+j+"\n"+request.j)
}
}
}
For all values of request's properties, it's showing up as undefined.
Also, if I don't litter my constructor with log calls, the log calls
don't happen in there and a log call after it won't happen either.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to mochikit+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---
Arnar Birgisson
2008-10-03 12:53:11 UTC
Permalink
Post by Eamonn Kearns
I'm afraid the problem was even more embarrassing than that.
request.addCallbacks is a method
request.addCallBacks is not.
Stupid dyslexia.
Don't feel bad. We all have these moments (or hours) where a typo is
staring us right in the face but yet we do not see it.

cheers,
Arnar

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MochiKit" group.
To post to this group, send email to ***@googlegroups.com
To unsubscribe from this group, send email to mochikit+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...