hi!
I'm working on a new method of doing Ajax calls utilizing streaming
responses. I've created a little javascript class (which depends on
prototype.js) that can interpret a stream of JSON objects separated by
semicolons. This class is based on prototype.
As an application of this, i created a Mongrel plug-in that streams
the upload status when given a qualified upload_id. It sends content
looking like this:
{"received":5939792,"status":200,"state":"uploading","size":36872784};
{"received":6398544,"status":200,"state":"uploading","size":36872784};
[...]
{"received":36479568,"status":200,"state":"uploading","size":
36872784};
{"received":36856400,"status":200,"state":"uploading","size":
36872784};
{"received":36872784,"status":200,"state":"done","size":36872784};
(The format of these JSON objects is the same that is being used in
the upload progress plug-in for Lighttpd 1.5 as described here
http://trac.lighttpd.net/trac/wiki/Docs:ModUploadProgress
)
Included with this package is the javascript class Ajax.Pull, and an
example Rails application.
http://s3.amazonaws.com/four.livejournal/20070708/mongrel_streaming_upload_progress-0.2.gem
http://s3.amazonaws.com/four.livejournal/20070708/mongrel_streaming_upload_progress-0.2.tgz
This should work with Safari 3 and Firefox. I haven't tested IE. When
I get around to it will add a routine to Ajax.Pull which falls back on
polling a URL for the JSON updates if the browser does not support
Ajax streaming. This plug-in already supports this sort of polling
with the ?single URL parameter.
ry
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---