Answer the question
In order to leave comments, you need to log in
How to set up ajax correctly?
here is the part of the action responsible for the ajax request
$module=$this->module;
if (Yii::$app->request->isAjax) {
$post=Yii::$app->request->post();
if(!empty($post)){
return $this->render('create', [
'found' =>null,
]);
}else{
$get=Yii::$app->request->get();
foreach ($module->models as $value){
if($value['class']===$get['className']){
$found =$value;
break;
}
}
return $this->render('create', [
'found' =>$found,
]);
}
}
var_dump($found); $(".sortable-ui").on('click','.wells .showDropFile',function(e){
e.preventDefault();
var url = $(this).data('url');
var id = $(this).parents('li.wells').attr('data-id');
var className = $(this).parents('li.wells').attr('data-model');
$.ajax({
type: "GET",
url:url,
data:"id="+id+"&className="+className,
success: function(data){
alert(url);
}
});
});
Answer the question
In order to leave comments, you need to log in
Why not the result of the loop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question