M
M
margaret_murka2021-10-29 10:43:42
AJAX
margaret_murka, 2021-10-29 10:43:42

Why doesn't reload after AJAX work?

Ajax processes the form and reloads the page under certain conditions.
The question is a little not correctly asked, the reload occurs, but the data change is not taken into account.
The user is authorized in Ajax, but the page thinks not when reloading.
On restart everything is fine.

$('#check_phone').click(function(){
  if($('#ok').val() == phone_ok){
    var $that = $('.login_form');
    formData = new FormData($that.get(0));
    $.ajax({
      url: '/local/ajax/auth/check_phone.php', // путь к php-обработчику
      type: 'POST', // метод передачи данных
      dataType: 'json', // тип ожидаемых данных в ответе
      data: formData,
      complete: function(data) {
        if (data) {
          // проверка на ошибки
          if(data.errors){
            alert(data.errors);
          }
          else{
            window.location.href = window.location.href;
          }
        }
      }
    });
  }
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-10-29
@Aleksandr-JS-Developer

There is a method to restartlocation.reload();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question