A
A
AlexSer2017-11-17 14:15:44
PHP
AlexSer, 2017-11-17 14:15:44

How to display the Alert widget in a modal window?

Hello! I want to display a message about the result of the operation in a modal window through the Alert widget.
I select a row in the table and get the UID number from there - the record identifier and pass it through Ajax to the controller, launch the corresponding action.

$('table tbody tr').on('click',function(){
        var e=$(this).attr('data-key');
        var uid = $('table tr:eq('+e+') td:eq(1)').text();
         $.ajax({
                url:'system/uid',
                type:"POST",
                data:{
                  UID:uid
                },
                success:function(data) {
                   //alert(data);
                }
            });

In action, respectively, there is a reception
public  function actionUid(){
    if (Yii::$app->request->isAjax) {
        if(Yii::$app->request->post('UID')) {
        Yii::$app->session->setFlash('success','<b>Успешно</a></b>');
        }
    }

}

My widget reacts only after page refresh.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konata Izumi, 2019-08-27
@fuckingawesomenigga

The standard php lib has a wonderful parse_url function (in this case it does not fit)
And for your case basename

M
Maxim Timofeev, 2017-11-17
@AlexSer

setFlash writes to the session, respectively, the Alert widget reads it from there only when rendering html on the server, when it executes yii (php). Anything without a reload is just js.
Options:
send text from the server to ajax request and display it in pre-prepared html, then showing this html
send ready-made html from the server and paste it in the right place, in a modal or somewhere else

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question