N
N
nagge1012018-06-21 20:45:02
JavaScript
nagge101, 2018-06-21 20:45:02

Error in jQuery code, can you help?

Toasters, hello)
In general, I have a site written in oop.
There is a button "Output" and when pressed, it should write to the database and display a window with a message.
All windows and everything is there, but when you click an error:
a2bfc5c3a6.jpg

The code itself:

$(document).ready(function() {
  $('form').submit(function(event) {
    if ($(this).attr('id') == 'no_ajax') {
      return;
    }
    var json;
    event.preventDefault();
    $.ajax({
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      data: new FormData(this),
      contentType: false,
      cache: false,
      processData: false,
      success: function(result) {
        json = jQuery.parseJSON(result);
        if (json.url) {
          window.location.href = '/' + json.url;
        } else {
          alert(json.status + ' - ' + json.message);
        }
      },
    });
  });
});


Without this file, everything works, the database is recorded but the window does not pop up and it just redirects to the page with the answer (a bit complicated scheme)

Please help me, why is this so?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor Nasonov, 2018-06-21
@kvonosan

result is apparently empty

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question