dojo: ‘load’ function on xhrGet not called

I had hard time finding this out, I will put it here.

My ‘load’ function set on xhrGet() object was not called at all upon successful ajax query. Query was performed but load function was simply ignored (no error, nothing).

I also directly registered another function through .addCallback() method, and same result. Plainly ignored!

After loosing half of my hair, I tried to remove ‘handleAs’ option too, and finally it worked. Both functions were triggered!

‘handleAs’ was set to ‘json’ and returned code is wrapped into textarea node as explained in js documentation (this is what caused below error, json data must be wrapped into <textarea> node when generated into an iframe, not through ajax requests).
Then I added an error callback (.addErrback()) logging provided response and finally an error message got displayed:

SyntaxError: missing } in XML expression message=missing } in XML expression


Always attach an Errback function, even if it’s just to log the response.

Post a Comment

Your email is never published nor shared. You're allow to say what you want...