Display an error if ajaxsource has an error
Display an error if ajaxsource has an error
I'm looking to display a alert if my ajaxsource comes up with an error while trying to create its json - this can happen for several reasons. The fnServerParams passed in may be invalid - such as when I'm passing in an id into a database table and that id doesn't exist. I want to tell the user that the data they entered is invalid.
This discussion has been closed.
Replies
Allan
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "../examples_support/server_processing.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.getJSON( sSource, aoData, function (json) {
/* check to see if json contains an error? */
fnCallback(json)
} );
}
} );
} );
[/code]
And I would actually create a different json structure for error conditions and check to see if that error node exists where I have /* check to see... */ ?
Thanks Allan!
Allan