Handing HTTP 30x..40x..50x
Handing HTTP 30x..40x..50x
Hi I am using Datatables with server-side and AJAX. Every thing works okay until session expires or some error is thown by server. I am using
[code]$.fn.dataTableExt.sErrMode = 'throw';[/code]
to avoid pop-up. I have to reload page when exception happens. I tried putting try/catch(e){document.location.reload()} around my datatable initialization call
[code]$('.datatable').dataTable( .....)[/code]
This does not seem to work though. I see exception in chrome toolbar(developer tools).
What am I doing wrong? Any suggestions on this?
Thanks and advance.
Regards
[code]$.fn.dataTableExt.sErrMode = 'throw';[/code]
to avoid pop-up. I have to reload page when exception happens. I tried putting try/catch(e){document.location.reload()} around my datatable initialization call
[code]$('.datatable').dataTable( .....)[/code]
This does not seem to work though. I see exception in chrome toolbar(developer tools).
What am I doing wrong? Any suggestions on this?
Thanks and advance.
Regards
This discussion has been closed.
Replies
[code]
function handleAjaxError( xhr, textStatus, error ) {
document.location.reload(true);
}
$(document).ready(function() {
$.fn.dataTableExt.sErrMode = 'throw';
$('.datatable').dataTable( {
"sDom": "<'row-fluid'<'span4'l><'span8'f>r>t<'row-fluid'<'span4'i><'span8'p>>",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "your URL",
"sPaginationType": "bootstrap",
"oLanguage": {
"sLengthMenu": "_MENU_ records per page"
},
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback,
"timeout": 15000,
"error": handleAjaxError
"error": handleAjaxError
});
},
......
[/code]
If anyone has better suggestion, please post it.