By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

Handling exception for PrototypeJs AJAX Call

RamananKalirajan
100+
P: 607
Hi guys, I am having a problem in Prototypejs AJAX, I am triggering the AJAX call and in the option i am using like the folowing code:

[HTML]new Ajax.Request(connection.url, {
method: (connection.method ? connection.method : 'post'),
on404: function(request){
alert("File Not Found Exception Occured ");
this.connections.waitPop();
this.isProcessing = false;
this.processNext();
}.bind(this),
onSuccess: function(transport) {
(connection.onSuccessHandler ? connection.onSuccessHandler(transport) : {});
}.bind(this),
onException: function(request,exception){
alert("Exception Occured "+exception.message);
this.connections.waitPop();
this.isProcessing = false;
this.processNext();
}.bind(this),
onComplete: function(){
alert("OnComplete");
this.connections.waitPop();
this.isProcessing = false;
this.processNext();
}.bind(this)
});[/HTML]

handler on404: has high priority. I made the AJAX call with URL which is not over there. The Exception handler onException is working but on404: is not working. Has anyone tried like this before.

Regards
Ramanan Kalirajan
Aug 6 '08 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
Why not use onFailure? For more information on callbacks, see this page.
Aug 6 '08 #2

RamananKalirajan
100+
P: 607
Hi Acoder, onFailure doesn't works for the FileNotFound Error. The hadler code in onException gets executed when I included my code with the onFailure case. Then I commented the onException handler and once again tried running my code. the thing is it is not working well. The onfailure handler is not invoked. Any suggestions

Regards
Ramanan Kalirajan
Aug 7 '08 #3

acoder
Expert Mod 15k+
P: 16,027
onFailure won't be invoked if on404 is invoked. Is there an error?
Aug 7 '08 #4

RamananKalirajan
100+
P: 607
See I am having the three handler altogether on404, onFailure, onException. I am giving an incorrect URL in the Ajax request. It's only invoking the onException Handler. Then I commented the onException handler and tried with the other two I got nothing. None of the handler is invoked. I placed on404 handler alone and tried with variable parameter type and then onFailur handler alone with variable parameter type. Nothing got invoked i don't know why. Any suggestions.

Regards
Ramanan Kalirajan
Aug 7 '08 #5

acoder
Expert Mod 15k+
P: 16,027
Make a simple function that just alerts the status or something and attach that to on404 instead just to test.
Aug 7 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.