View Full Version : Readers must eval javascript!

19 Apr 2007, 1:08 PM
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.

19 Apr 2007, 4:02 PM
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:

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.

19 Apr 2007, 9:33 PM
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. :D
So, I have tested it and it is working properly. :)
Many thanx!

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

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

19 Apr 2007, 10:21 PM
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:

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

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