Ajax call, triggering onException. but.. what exception?

942 views
Skip to first unread message

revivedk

unread,
Aug 7, 2008, 7:58:07 AM8/7/08
to Prototype & script.aculo.us
I've got a Ajax.Request, that triggers the onException, in internet
explorer 7.

how do I actually figure out what that exception was, so that I can
fix it.

it works fine in both firefox and safari.


new Ajax.Request(element.href, {
method: 'get',
asynchronous: false,
onSuccess: function(transport) {
$('lbContent').update(transport.responseText);
},
evalJS: true,
//debuggin
onCreate: function (e) {
alert('Created');
},
onException: function (e) {
alert('an Exception happend');
},
onFailure: function (e) {
alert('ERROR: ' + e.responseText);
}
});

Leonardo Cidral

unread,
Aug 7, 2008, 8:18:19 AM8/7/08
to prototype-s...@googlegroups.com
I use it for see details of the exception...

        dsException = "\n=================================================================\n";
        dsException += "Objeto: EXCEPTION";
        dsException += "\n=================================================================\n";
        dsException += "exception.name: ";
        dsException += e.name
        dsException += "\n";
        dsException += "exception.number: ";
        dsException += e.number;
        dsException += "\n";
        dsException += "exception.description: ";
        dsException += e.description;
        dsException += "\n**************************************************************************************************";
        alert(dsException);


hugs,
Leonardo Cidral



2008/8/7 revivedk <Timso...@gmail.com>

revivedk

unread,
Aug 10, 2008, 7:39:27 AM8/10/08
to Prototype & script.aculo.us
so, Ill have to do something like the following?

//ajax call..
{
onException: function(e) {
dsException =
"\n=================================================================
\n";
dsException += "Objeto: EXCEPTION";
dsException +=
"\n=================================================================
\n";
dsException += "exception.name: ";
dsException += e.name
dsException += "\n";
dsException += "exception.number: ";
dsException += e.number;
dsException += "\n";
dsException += "exception.description: ";
dsException += e.description;
dsException +=
"\n**************************************************************************************************";
alert(dsException);
},



oh, and.
is " dsException += "Objeto: EXCEPTION";" spelled correct, or
did you mean Object: EXCEPTION ?

On Aug 7, 2:18 pm, "Leonardo Cidral" <lcid...@gmail.com> wrote:
> I use it for see details of the exception...
>
>         dsException =
> "\n=================================================================\n";
>         dsException += "Objeto: EXCEPTION";
>         dsException +=
> "\n=================================================================\n";
>         dsException += "exception.name: ";
>         dsException += e.name
>         dsException += "\n";
>         dsException += "exception.number: ";
>         dsException += e.number;
>         dsException += "\n";
>         dsException += "exception.description: ";
>         dsException += e.description;
>         dsException +=
> "\n**************************************************************************************************";
>         alert(dsException);
>
> hugs,
> Leonardo Cidral
>
> 2008/8/7 revivedk <Timsoren...@gmail.com>

T.J. Crowder

unread,
Aug 10, 2008, 8:59:45 AM8/10/08
to Prototype & script.aculo.us
> oh, and.
> is " dsException += "Objeto: EXCEPTION";" spelled correct, or
> did you mean Object: EXCEPTION ?

Remember that this is the *world* wide web. The bits in quotes are
just literal text for display purposes; you can use whatever you
want. In his case, he used the correct word for "object" in his
language ("objeto" is "object" in at least Portuguese and Spanish that
I know of [though not, as you might otherwise suspect from the name
"Leonardo", Italian; Italian for "object" is "oggetto"]).
--
T.J. Crowder
tj / crowder software / com

revivedk

unread,
Aug 10, 2008, 12:27:42 PM8/10/08
to Prototype & script.aculo.us
Oh, right, ofcourse.

I tried the function stated above. and it is triggered on the
exception, but all the values are just stated as undefined. and that,
ofcourse doesn't help very much.

Leonardo Cidral

unread,
Aug 11, 2008, 7:50:52 AM8/11/08
to prototype-s...@googlegroups.com
//REFERENCIA ---->>  http://prototypejs.org/api/ajax/options
var callbacksGlobais = {
    lastURL: "",

    //onCreate (this is actually a callback reserved to AJAX global responders)
    onCreate: function(request, transport, json) {
        $("nrReqPend").innerHTML = Ajax.activeRequestCount;

        this.startReq = new Date();

        if(Ajax.activeRequestCount <= 1){
            app.msgAguarde(true); //mostra msg de aguarde
        }

        if (this.lastURL == request.url) {
            throw new Error("Esta ação já foi requisitada recentemente, aguarde.");
        } else {
            this.lastURL = request.url;
        }
    },

    //onUninitialized (maps on Created)
    //(Not guaranteed) Invoked when the XHR object was just created.
    onUninitialized: function(t) {
        xdebug.saida("onUninitialized " + t.status + ' -- ' + t.statusText);
    },

    //onInteractive (maps on Response being received)
    //(Not guaranteed) Triggered whenever the requester receives a part of the response (but not the final part), should it be sent in several packets.
    onInteractive: function(t) {
        xdebug.saida("onInteractive " + t.status + ' -- ' + t.statusText);
    },

    //onLoading (maps on Initialized)
    //(Not guaranteed) Triggered when the underlying XHR object is being setup, and its connection opened.
    onLoading: function(t) {
        xdebug.saida("Carregando... " + t.status + ' -- ' + t.statusText);
    },

    //onLoaded (maps on Request sent)
    //(Not guaranteed) Triggered once the underlying XHR object is setup, the connection open, and ready to send its actual request.
    onLoaded: function(t) {
        xdebug.saida("Carregado! " + t.status + ' -- ' + t.statusText);
    },

    /*
    //onXYZ (numerical response status code), onSuccess or onFailure (see below)
    on404: function() {

    },
    */

    onComplete: function () {
        $("nrReqPend").innerHTML = Ajax.activeRequestCount;
        if(Ajax.activeRequestCount == 0){
            app.msgAguarde(false); //oculta msg de aguarde
        }
        endReq = new Date();
        xxx = (endReq.getTime() - this.startReq.getTime())/1000;

        tmp = document.title.split("-");
        document.title = tmp[0] + " - ["+xxx+"s]";

        if ($("tmp_janelas").innerHTML.indexOf("Maximum execution time of") > 0) {
            alert("Ocorreu um erro!\n\n O servidor está ocupado, tente novamente.");
        } else if ($("tmp_janelas").innerHTML.indexOf("Allowed memory size of") > 0) {
            alert("Ocorreu um erro!\n\n O servidor não conseguiu processar esta requisição por falta de memória.");
        }

        if ($("tmp_janelas").innerHTML.indexOf("protegido por leis de direitos autorais") > 0) {
            Event.stopObserving(window, 'beforeunload', app.Sair);
            document.location = "index.php";
        }
        window.status = "Concluído";
    },

    onFailure: function(t) {
       alert('Falha\nError ' + t.status + ' -- ' + t.statusText);
    },

    onException: function(req,exception) {
        dsException = "\n\n";
        dsException += "**************************************************************************************************\n";
        dsException += "                                          AJAX - EXCEPTION                                        \n";
        dsException += "\n";
        dsException += "Objeto: REQ";
        dsException += "req.transport.responseText: \n";
        dsException += req.transport.responseText;

        dsException += "\n=================================================================\n";
        dsException += "Objeto: EXCEPTION";
        dsException += "\n=================================================================\n";
        dsException += "exception.name: ";
        dsException += exception.name

        dsException += "\n";
        dsException += "exception.number: ";
        dsException += exception.number;

        dsException += "\n";
        dsException += "exception.description: ";
        dsException += exception.description;
        dsException += "\n**************************************************************************************************";
        xdebug.saida(dsException);
        Ajax.activeRequestCount--;
        this.onComplete();
    }
};
Ajax.Responders.register(callbacksGlobais);




2008/8/10 revivedk <Timso...@gmail.com>

revivedk

unread,
Sep 3, 2008, 8:22:53 AM9/3/08
to Prototype & script.aculo.us
I have No idea what to do with that.

anyways, I uploaded my script, for a live demo, to make it easier
seeing what could be wrong? (btw, press ESC to close the lightbox)
http://lightbox.wizzdev.dk, remember, its in INTERNET EXPLORER it
fails. working fine in firefox/safari/Chrome
> "************************************************************************** ************************\n";
> 2008/8/10 revivedk <Timsoren...@gmail.com>

revivedk

unread,
Sep 29, 2008, 5:27:11 AM9/29/08
to Prototype & script.aculo.us
ah. I figured it out.
it was so blatantly obvious. I can't believe I didn't notice. the
error was triggered because I was fetching google.com and therefore
violating the same site policy.
Reply all
Reply to author
Forward
0 new messages