A
A
arab7892016-03-22 12:30:11
Yii
arab789, 2016-03-22 12:30:11

How can I prevent a request from being resubmitted while the first one is being executed?

There are actions that create, modify pages, and so on. How to make UserIgnor so that when the user clicked save or change, he could not do anything else until the action was performed? That the same request did not turn out.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
arab789, 2016-03-23
@arab789

I solved it like this:
In CActiveForm we write in the form

$form=$this->beginWidget('CActiveForm', array(
  'id'=>'page-form',
  'enableAjaxValidation'=>false,
        'htmlOptions'=>array(
                 'onsubmit'=>'return this.sub.disabled=true;
        ),
       
));

where sub is the id of the button.
echo CHtml::submitButton('Сохранить', array('id'=>'sub'));

A
Anton Shcherbakov, 2016-03-22
@WestTrade

Send an AJAX request until a positive status response is received - disable the submit button. If an error is received - similarly, unblock the button and allow the data to be sent again.

M
Maxim Timofeev, 2016-03-23
@webinar

Create a variable in the session, for example "mazafaka", add it to beforeaction, delete it in afteraction, and before adding it, check whether it exists, if it exists, create a flash message and redirect to the previous page, if not, create

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question