Jump to content

gevensen

Members
  • Posts

    206
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

gevensen's Achievements

Member

Member (2/5)

0

Reputation

  1. I have some routines I use over and over Is there a way to put the error section in a file of its own For example I use a routine below <script type="text/javascript"> $('.MYTRIGGER').live('change', function() { var MyData=''; $("#jq_tab").val('0'); var NameData=$(this).attr('name'); var IdData=$(this).attr('id'); MyData=MyData+'CID='+NameData;; MyData=MyData+'&Field='+IdData; MyData=MyData+'&FieldValue='+$(this).val(); $.ajax( { cache:false, timeout:28000, url : 'MyPhp.php', type : 'post', data : MyData, success : function( resp ) { $("#jq_tab").val('1'); return(false); }, error: function(xhr, status, error) { var stat = $("#jq_tab").val(); $("#main_page_div").unmask_div(); if(stat!='1'){ if (xhr.status === 0) { alert('Unable to connect to Network'); } else if (xhr.status == 404) { alert('Requested page not found. [404]'); } else if (xhr.status == 500) { alert('Internal Server Error [500].'); } else if (exception === 'parsererror') { alert('Requested JSON parse failed.'); } else if (exception === 'timeout') { alert('System Timeout (Internet Congestion or server slow)'); } else if (exception === 'abort') { alert('Ajax request aborted.'); } else { alert('Unspecified Error #' + xhr.responseText); } } return false; } // eof error function }); }); </script> Since the below is common error: function(xhr, status, error) { var stat = $("#jq_tab").val(); $("#main_page_div").unmask_div(); if(stat!='1'){ if (xhr.status === 0) { alert('Unable to connect to Network'); } else if (xhr.status == 404) { alert('Requested page not found. [404]'); } else if (xhr.status == 500) { alert('Internal Server Error [500].'); } else if (exception === 'parsererror') { alert('Requested JSON parse failed.'); } else if (exception === 'timeout') { alert('System Timeout (Internet Congestion or server slow)'); } else if (exception === 'abort') { alert('Ajax request aborted.'); } else { alert('Unspecified Error #' + xhr.responseText); } } return false; } // eof error function Is there a way to store the error function in a common file?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.