I have the following code:
<script type='text/javascript'> $(document).ready(function() { $('#Save').click(function() { $.post('url', { 'data': 'data' }, function(data) { alert(data); }); }); }); </script>
I’m testing this script, and one of the tests I’m making is, I just close the asp.net web development server, and click the button.
IE says ‘access denied’ error, I want to catch any error that occurs here, and display a friendly message to the user in this case.
I trying to use try/catch but didn’t work…
Any clue?
Use the
$.ajax()method instead. It has a hook for errors.For example: