S
S
Sergey Bard2018-06-12 15:57:31
Yii
Sergey Bard, 2018-06-12 15:57:31

Why does the recursive function reload the page?

Hello everyone, I continue to ask questions about yii), in general, there is a modal window in which I placed the form, there is also a button in the modal when I click on which I make a request to a third-party service, through queue, Systemd is running on the server, and if there is something it executes it right away, there are several requests, I made a request and I need to wait until the answer is received and update the form, but here's the problem, I update the form via pjax inside ActiveForm, ('data-pjax' => true and 'enctype' => 'multipart/form-data',) and in order to wait for a response, I use this construction

protected function CheckDoneQueue($id)
  {
    if(Yii::$app->queue->isDone($id)){
      return true;
    } else {
      return $this->CheckDoneQueue($id);
    }
  }

and it turns out that with this design, a request works for me, but then instead of just updating the form via pjax, I update the entire page, when I remove this function, everything works fine, only the form is updated with empty data, i.e. he abandoned the queue and went on, and the queue writes data to the database. Tell me what could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arman, 2018-06-12
@serg_small_developer

pjax I don’t remember exactly, but the yii.js standards take over the response first and if it encounters the location header, it simply redirects the entire page to it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question