[jQuery] Re: how to capture error 500/404 ?
Solution of your problem: error: function (xhr, ajaxOptions, thrownError) { if(xhr.status == 404) { // some error } else if(xhr.status == 403) { // another error } else { // default error } } On 24. Nov, 16:21 h., ricardobeat ricardob...@gmail.com wrote: The XHR object and the error are passed as arguments to the ajaxError callback: $.ajaxError(function(event, XHRObject, options, errorThrown){ console.log( XHRObject.responseText, errorThrown ); }); seehttp://docs.jquery.com/Ajax/ajaxError#callback On Nov 24, 4:09 am, Adwin Wijaya adwin.wij...@gmail.com wrote: how about using ajaxError events ? but I dont know how to capture the response text if 404 / 500 errors occured. can i use that instead of $.ajax ... ? thanks ! On Nov 24, 12:18 pm, Jeffrey Kretz jeffkr...@hotmail.com wrote: The best way would be to use the $.ajax call directly (both the post and the get function call $.ajax internally). $.ajax({ type:'GET', url:'somepath.php', dataType:'json', success:do_something, error:do_something_else }); function do_something(results) { /// } function do_something_else() { /// } JK -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Adwin Wijaya Sent: Sunday, November 23, 2008 8:58 PM To: jQuery (English) Subject: [jQuery] how to capture error 500/404 ? Hi, how to capture error that produced by server (err 505 or 404) inside $.post() and $.get() ? thanks !!!
[jQuery] Re: how to capture error 500/404 ?
Thanks anyway .. i found simpler solutions as referred by richo :) $(document).ajaxError(function(event, request, setting) { var re = /br\/|br/g; // for replacing all br/ with empty string in error 404 var txt = request.responseText.replace(re,); jqalert(txt,Server Error); }); On Dec 15, 8:57 am, MareceK ma...@tutoky.com wrote: Solution of your problem: error: function (xhr, ajaxOptions, thrownError) { if(xhr.status == 404) { // some error } else if(xhr.status == 403) { // another error } else { // default error } } On 24. Nov, 16:21 h., ricardobeat ricardob...@gmail.com wrote: The XHR object and the error are passed as arguments to the ajaxError callback: $.ajaxError(function(event, XHRObject, options, errorThrown){ console.log( XHRObject.responseText, errorThrown ); }); seehttp://docs.jquery.com/Ajax/ajaxError#callback On Nov 24, 4:09 am, Adwin Wijaya adwin.wij...@gmail.com wrote: how about using ajaxError events ? but I dont know how to capture the response text if 404 / 500 errors occured. can i use that instead of $.ajax ... ? thanks ! On Nov 24, 12:18 pm, Jeffrey Kretz jeffkr...@hotmail.com wrote: The best way would be to use the $.ajax call directly (both the post and the get function call $.ajax internally). $.ajax({ type:'GET', url:'somepath.php', dataType:'json', success:do_something, error:do_something_else }); function do_something(results) { /// } function do_something_else() { /// } JK -Original Message- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of Adwin Wijaya Sent: Sunday, November 23, 2008 8:58 PM To: jQuery (English) Subject: [jQuery] how to capture error 500/404 ? Hi, how to capture error that produced by server (err 505 or 404) inside $.post() and $.get() ? thanks !!!
[jQuery] Re: how to capture error 500/404 ?
The XHR object and the error are passed as arguments to the ajaxError callback: $.ajaxError(function(event, XHRObject, options, errorThrown){ console.log( XHRObject.responseText, errorThrown ); }); see http://docs.jquery.com/Ajax/ajaxError#callback On Nov 24, 4:09 am, Adwin Wijaya [EMAIL PROTECTED] wrote: how about using ajaxError events ? but I dont know how to capture the response text if 404 / 500 errors occured. can i use that instead of $.ajax ... ? thanks ! On Nov 24, 12:18 pm, Jeffrey Kretz [EMAIL PROTECTED] wrote: The best way would be to use the $.ajax call directly (both the post and the get function call $.ajax internally). $.ajax({ type:'GET', url:'somepath.php', dataType:'json', success:do_something, error:do_something_else }); function do_something(results) { /// } function do_something_else() { /// } JK -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Adwin Wijaya Sent: Sunday, November 23, 2008 8:58 PM To: jQuery (English) Subject: [jQuery] how to capture error 500/404 ? Hi, how to capture error that produced by server (err 505 or 404) inside $.post() and $.get() ? thanks !!!
[jQuery] Re: how to capture error 500/404 ?
The best way would be to use the $.ajax call directly (both the post and the get function call $.ajax internally). $.ajax({ type:'GET', url:'somepath.php', dataType:'json', success:do_something, error:do_something_else }); function do_something(results) { /// } function do_something_else() { /// } JK -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Adwin Wijaya Sent: Sunday, November 23, 2008 8:58 PM To: jQuery (English) Subject: [jQuery] how to capture error 500/404 ? Hi, how to capture error that produced by server (err 505 or 404) inside $.post() and $.get() ? thanks !!!
[jQuery] Re: how to capture error 500/404 ?
how about using ajaxError events ? but I dont know how to capture the response text if 404 / 500 errors occured. can i use that instead of $.ajax ... ? thanks ! On Nov 24, 12:18 pm, Jeffrey Kretz [EMAIL PROTECTED] wrote: The best way would be to use the $.ajax call directly (both the post and the get function call $.ajax internally). $.ajax({ type:'GET', url:'somepath.php', dataType:'json', success:do_something, error:do_something_else }); function do_something(results) { /// } function do_something_else() { /// } JK -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Adwin Wijaya Sent: Sunday, November 23, 2008 8:58 PM To: jQuery (English) Subject: [jQuery] how to capture error 500/404 ? Hi, how to capture error that produced by server (err 505 or 404) inside $.post() and $.get() ? thanks !!!