Fabian Schmengler
Fabian Schmengler

Reputation: 24576

How to simulate/test AJAX exception handler?

I have a PrototypeJS AJAX request like this (third party code):

new Ajax.Request(url,
{
    method: 'get',
    onException: function(transport, e)
    {
        //...
    },
    onComplete: function(transport)
    {
        //...
    }
});

and want to test the behavior of onException. I have control over the server side, so I can change the response. But simply returning a 500 status does not do the trick, it is still handled by onComplete.

So what possibilities do I have to trigger the onException handler?

Upvotes: 0

Views: 112

Answers (1)

Serge K.
Serge K.

Reputation: 5323

onException is only fired when there was an exception while dispatching other callbacks, see here, in Ajax response callbacks. So I'm not sure there is a way to test it.

EDIT:

I read (in french, didn't find anything in english) that if you make a cross-domain request it fires the vent.

Upvotes: 2

Related Questions