Как поймать исключения/ошибки JavaScript? (Для входа их в сервер)

onSuccess: function(event, fields) {
              dim();
              }
<час>

пример

$(document)
    .ready(function() {
      $('.ui.form')
        .form({
          fields: {
            trailer: {
              identifier  : 'trailer',
              rules: [
                {
                  type   : 'empty',
                  prompt : 'Please select a Trailer'
                }
              ]
            },
            movie: {
              identifier  : 'movie',
              rules: [
                {
                  type   : 'empty',
                  prompt : 'Please select a Movie'
                }            
              ]
            }
          },
              onSuccess: function(event, fields) {
              dim();
              }
        })
      ;
    })
  ;
15
задан Community 23 May 2017 в 12:22
поделиться

1 ответ

I use this function in all my projects:

window.onerror = function(m,u,l){
    jQuery.post("ajax/js_error_log.php",
        { msg: m,
          url: u,
         line: l,
       window: window.location.href });
    return true};

Make sure it is the very first javascript the browser receives or at least precedes any potentially error-causing code. Requires jQuery of course, but you could code ajax functions in pure javascript if you wanted to.

Please note: this will not help you if you have a syntax error. All javascript instantly dies if there is a syntax error.

27
ответ дан 1 December 2019 в 02:37
поделиться
Другие вопросы по тегам:

Похожие вопросы: