I
I
Ilya2020-06-07 10:15:51
JavaScript
Ilya, 2020-06-07 10:15:51

Why is it that if you write AJAX like this ... then it works in google, but not in FireFox?

If you write an Ajax request like this:

$.ajax({
  url: url_Page,
  type: "POST",
  data: { new_val: newVal, id: id, field: field },
  beforeSend: function () {
    $("#loader").fadeIn();
  },
  success: function (res) {
    $("#mes-edit")
      .text(res)
      .delay(500)
      .fadeIn(1000, function () {
        $("#mes-edit").delay(1000).fadeOut();
      });
  },
  error: function () {
    alert("Error!");
  },
  complete: function () {
    $("#loader").delay(500).fadeOut();
  },
});

That and google and in FireFox everything works well. But if I want to write the code as in the picture, then in FireFox the request does not seem to be sent to the server, and the giveaway in the success response works, but in google everything also continues to work fine. I have some ajax that have the same structure, and I wanted to somehow repeat less in the code(
What is the reason? If you have at least some ideas? I will be grateful for any answer!

$.ajax({
  url: url_Page,
  type: "POST",
  data: { new_val: newVal, id: id, field: field },
  beforeSend: beforeSend(),
  success: messageSuccess(res),
  error: Error(),
  complete: complete()
})

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question