Results 1 to 4 of 4

Thread: Readers must eval javascript!

  1. #1
    Ext User amon's Avatar
    Join Date
    Apr 2007
    Location
    Budapest
    Posts
    109

    Default Readers must eval javascript!

    Hello!
    Can I turn on javascript eval in all of readers?

    I use grid with xmlreader in an admin board. If I leave my computer for a while, and I click on refresh, the session has expired. It is normal. But, my board can not to grab this info through readers.

    How can I turn on eval js in all of loaders? (If session had expired, I sent a window.location.reload(); command)

    Or can I do anything else to fix this problem?

    If I properly understand the onload callback, this is called after the parsing records. If it is true, than I cannot catch the "session expired" message.

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    The JsonReader does eval the responseText. But you are using XmlReader, so...

    It would be good if you could add a handler to the HttpProxy's "load" event and examine the response object, and take appropriate action, but the response object isn't passed to the Proxy's "load" event. I think it should be. Jack, what do you say? This would be a good enhancement.

    What you can do is add an interceptor to the reader's read method which examines the data before the XmlReader's read method sees it:

    Code:
        myReader.read.createInterceptor(function(response) {
            // examine the response object here.
            // perhaps, if the "Content-Type" header is "text/javascript", you could just eval
            // the responseText
        });
    Read the docs on Function.

  3. #3
    Ext User amon's Avatar
    Join Date
    Apr 2007
    Location
    Budapest
    Posts
    109

    Default

    Animal:
    Oh, thank you. It's a good idea. I have not read the doc of that method until now. It is a very useful thing.
    So, I have tested it and it is working properly.
    Many thanx!

    Jack:
    The first line in my virtual wish-list is: the loaders eval the response (just for themselves) if that is text/javascript.

    note:
    In my previous post the "refresh" means my refresh method of grid, and not the button of the browser.

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    You can't just always eval the response.

    The best thing would be for the HttpProxy's "load" event to be passed the XHR response, so then developers could examine the response and take action.

    Also for the return status from the handler to be allowed to abort the load.

    ie in Ext.data.HttpProxy.loadResponse:

    Code:
            if (this.fireEvent("load", this, o, o.request.arg, response) !== false) {
                o.request.callback.call(o.request.scope, result, o.request.arg, true);
            }
    Then you'd just use

    Code:
        myProxy.on("load", function(p, o, arg, resopnse) {
            // examine response. perform appropriate action
            // If data cannot be loaded return false;
        }, this);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •