обратный вызов jquery POST не работает без параметра type - PullRequest
0 голосов
/ 09 октября 2019

Я выполняю вызов POST и хочу обработать error, однако обратный вызов success не вызывает, если не введен параметр 'type'.

Я пыталсяследующими способами.

Это работает, но так как я также хочу обработать часть ошибки, я не могу использовать это.

$.post(myurl, {
  mydatatobesent
}, function(resp) {
  console.log("done is called");
  resolve(true);
}, "text");

Другие испытания:

$.post(myurl, {
  mydatatobesent
}, function(resp) {
  console.log("done is called");
  resolve(true);
}, function(error) {
  console.log("error is called");
  reject(error);
}, "text");


$.post(myurl, {
  mydatatobesent
}, function(resp) {
  console.log("done is called");
  resolve(true);
}, "text", function(error) {
  console.log("error is called");
  reject(error);
});


$.post(myurl, {
  mydatatobesent
}).done(function(resp) {
  console.log(resp)
}).fail(function(fail) {
  console.log(fail
});


$.post(myurl, {
  mydatatobesent
}, "text").done(function(resp) {
  console.log(resp)
}).fail(function(fail) {
  console.log(fail
});

ОБНОВЛЕНИЕ : На последнем испытании вызывается обработчик fail.

CONSOLE

enter image description here

ОБНОВЛЕНИЕ

enter image description here enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...