I played with it a little more, and I had it working (something about
spacing the requests apart).  Sadly, this approach hasn't panned out
as I would like.  With each chunk the browser seems to get slower and
slower, almost in an exponential way.  Could that be due to how I keep
calling XmlHttp -> fDone -> XmlHttp -> fDone until I'm deep enough to
have fetched all the chunks?

@David Huynh, what's weird is that everything loads fine with the
regular application/json importer.  It's entirely possible I'm
returning bad data, but at this point all the service does is take the
JSON that would have originally been used and just chunks it up,
adding a little extra status information.

On May 19, 10:17 pm, David Huynh <[email protected]> wrote:
> fractile81 wrote:
> > I'm helping out matt in
> >http://groups.google.com/group/simile-widgets/browse_thread/thread/73...
> > to try and get the app to run a bit smoother (the browser lag in FF is
> > terrible!).  I've been playing with the idea of loading JSON in chunks
> > using a service that takes an offset, then adding the data to
> > Exhibit.  This works, but is still really slow to load.
>
> > What I would like to do is programmatically load each JSON chunk once
> > a successful request has been made.  Here's what I think should work:
>
> > /*==================================================
> >  *  Exhibit.ExhibitJSONChunkImporter
> >  *==================================================
> >  */
>
> > Exhibit.ExhibitJSONChunkImporter = {
> > };
> > Exhibit.importers["application/json-chunk"] =
> > Exhibit.ExhibitJSONChunkImporter;
>
> > Exhibit.ExhibitJSONChunkImporter.load = function(link, database, cont)
> > {
> >     var url = typeof link == "string" ? link : link.href;
> >     var last_chunk = -1;
> >     var items = [];
> >     url = Exhibit.Persistence.resolveURL(url);
>
> >     var fChunk = function(xmlhttp) {
> >            try {
> >                    var o = null;
> >                    try {
> >                            o = eval("(" + xmlhttp.responseText + ")");
> >                    } catch (e) {
> >                            
> > Exhibit.UI.showJsonFileValidation(Exhibit.l10n.badJsonMessage(url,
> > e), url);
> >                    }
>
> >                    if (o != null) {
> >                            if (o.status == 'ok') {
> >                                    last_chunk = o.chunk;
>
> >                                    // THIS NEXT LINE DOESN'T WORK EVERY 
> > TIME!
> >                                    database.loadData(o, 
> > Exhibit.Persistence.getBaseURL(url));
>
> >                                    if (last_chunk + 1 < o.chunks) {
> >                                            return true;
> >                                    }
> >                            } else {
>
> >                            }
> >                    }
> >            } catch (e) {
> >                    SimileAjax.Debug.exception(e, "Error loading Exhibit 
> > JSON chunk
> > data from " + url);
> >            }
>
> >            return false;
> >    }
>
> >     var fError = function(statusText, status, xmlhttp) {
> >         Exhibit.UI.hideBusyIndicator();
> >         Exhibit.UI.showHelp(Exhibit.l10n.failedToLoadDataFileMessage
> > (url));
> >         if (cont) cont();
> >     };
>
> >     var fDone = function(xmlhttp) {
> >            try {
> >                    if (fChunk(xmlhttp)) {
> >                            SimileAjax.XmlHttp.get(url + '?chunk=' + 
> > (last_chunk+1),
> > fError, fDone);
> >                    } else {
> >                            Exhibit.UI.hideBusyIndicator();
> >                            // Alternate database.loadItems(); can go here
> >                    }
> >            } finally {
> >                    if (cont) cont();
> >            }
> >     };
>
> >     Exhibit.UI.showBusyIndicator();
> >     SimileAjax.XmlHttp.get(url, fError, fDone);
> > }
>
> > In there I try to call database.loadData(); for each chunk of JSON I
> > receive.  This works for the first couple of chunks (I have a lot of
> > chunks), but I eventually get the following errors:
>
> > TypeError: this._dom is undefined "Error firing event of name
> > onItemsChanged" - debug.js (line 53)
> > Error firing event of name onItemsChanged "Error firing event of name
> > onAfterLoadingItems" - debug.js (line 53)
> > Database.loadItems failed "Error firing event of name
> > onAfterLoadingItems" - debug.js (line 53)
> > Error loading Exhibit JSON chunk data from http://<pathtoservice>/chunk.php
> > "Error firing event of name onAfterLoadingItems" - debug.js (line 53)
> > Error firing event of name onAfterLoadingItems "XmlHttp: Error
> > handling onReadyStateChange" - debug.js (line 53)
>
> > So I have two questions: 1) is database.loadItems(); capable of adding
> > data over multiple calls like I was hoping, or is there another
> > function/process I should try using?  2) I'm assuming the errors I'm
> > getting are related to my using the database.loadItems(); function the
> > way that I am -- is this assumption correct, or is there another place
> > I should be looking (apologies, I don't know this code very well yet)?
>
> > Thanks for any input!
>
> Craig,
>
> That sounds like the latest data chunk got loaded just fine but then
> something in it caused perhaps a view or a facet to throw an exception.
> Do you know which chunk that is?
>
> David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SIMILE Widgets" 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/simile-widgets?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to