Answer the question
In order to leave comments, you need to log in
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);
}
});
public function actionUid(){
if (Yii::$app->request->isAjax) {
if(Yii::$app->request->post('UID')) {
Yii::$app->session->setFlash('success','<b>Успешно</a></b>');
}
}
}
Answer the question
In order to leave comments, you need to log in
The standard php lib has a wonderful parse_url function (in this case it does not fit)
And for your case basename
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 questionAsk a Question
731 491 924 answers to any question