I've just started trying out FORKjs (ok... i've just been using it for
all of 30 mins now), and basically, i'm trying to replace all my
prototype.js calls with FORKjs calls. So far, so good, I especially
like the ability to do straight PUTs and DELETEs, without
piggyback'ing on POST. Kudos!!!
I have a funny problem with FORK.Mutate.update(), I've set up a poll,
that looks like (it replaces a projototype Ajax.PriodicalUpdater()
call):
function realtime_status()
{
var el = document.getElementById('status');
new FORK.Ajax(
'GET',
'/status/',
{
onComplete: function(o) {
FORK.Mutate.update(el, o.responseText);
},
after: function(o) {
setTimeout(realtime_status, 10000);
}
}
);
}
It works perfectly, but once in a while, when I'm doing a page
refresh, I get this error in Firebug:
html has no properties
stripScripts(undefined)mutate.js (line 34)
_insert(p#status, undefined, undefined, function(),
function())mutate.js (line 131)
insertBottom(p#status, undefined, undefined)mutate.js (line 165)
update(p#status, undefined, undefined)mutate.js (line 55)
onComplete(Object status=0 statusText=communication failure)main.js
(line 59)
doCallback("onComplete")ajax.js (line 215)
middleCallback()ajax.js (line 312)
handleReadyState4()ajax.js (line 296)
onReadyStateChange()ajax.js (line 223)
onreadystatechange()ajax.js (line 53)
[Break on this error] return html.replace(this.scriptRegExp, '');
I guess this happens when I refresh during a Mutate update, I'm not
sure, but I think this traceback could help point it out to someone
more in the know (aka. Peter :P)
On 2/11/07, essiene <ess...@gmail.com> wrote:
>
> I've just started trying out FORKjs (ok... i've just been using it for
> all of 30 mins now), and basically, i'm trying to replace all my
> prototype.js calls with FORKjs calls. So far, so good, I especially
> like the ability to do straight PUTs and DELETEs, without
> piggyback'ing on POST. Kudos!!!
Without piggybacking? You are using ajaxRails.js or not? I don't think
it is a good idea to use straight PUT and DELETE calls in today's web.
That is why Prototype and the Fork ajaxRails.js scripts do piggyback
on POST. Anyway your problem below is with a GET and so this is a
different issue.
Do you have an example posted live?
When you look at the XHR in Firebug's console what do you see for the
GET request's response headers and body?
It looks like o.responseText is empty for some reason. This would mean
the Mutate library is ok and that something is going wrong with with
either ajax.js or your server side script that is responding.
I found an unrelated bug yesterday in ajax.js. On lines 309 and 310
change "status" to "this.status" two times.
Peter
--
Fork JavaScript: http://forkjavascript.org
Hi,
On 2/11/07, essiene <ess...@gmail.com> wrote:
>
> I've just started trying out FORKjs (ok... i've just been using it for
> all of 30 mins now), and basically, i'm trying to replace all my
> prototype.js calls with FORKjs calls. So far, so good, I especially
> like the ability to do straight PUTs and DELETEs, without
> piggyback'ing on POST. Kudos!!!
Without piggybacking? You are using ajaxRails.js or not? I don't think
it is a good idea to use straight PUT and DELETE calls in today's web.
That is why Prototype and the Fork ajaxRails.js scripts do piggyback
When you look at the XHR in Firebug's console what do you see for the
GET request's response headers and body?
It looks like o.responseText is empty for some reason. This would mean
the Mutate library is ok and that something is going wrong with with
either ajax.js or your server side script that is responding.
I found an unrelated bug yesterday in ajax.js. On lines 309 and 310
change "status" to "this.status" two times.
There is a reason for the POST piggybacking. It has to do with proxys
between the client and the server. Not all proxies can deal with verbs
other than GET, POST, HEAD. This is what I'm told anyway. I think it
would be conservative to look into this in more detail if you are
going to start using other verbs for real. If the Rails folks could do
that I'm sure they would be doing it.
It's a little confusing. What kind of "refresh"? Browser refresh or
some html button you have built in the page? Perhaps you should be
calling the abort() property of the object returned by new
FORK.Ajax()? If there is a communicaiton problem then the solution is
not to touch the mutate code. The solution is to make sure that the
mutate code is only called if the ajax request was successful.
I think it
would be conservative to look into this in more detail if you are
going to start using other verbs for real. If the Rails folks could do
that I'm sure they would be doing it.
Perhaps you should be
calling the abort() property of the object returned by new
FORK.Ajax()? If there is a communicaiton problem then the solution is
not to touch the mutate code. The solution is to make sure that the
mutate code is only called if the ajax request was successful.