Answer the question
In order to leave comments, you need to log in
Yii2 Pass variable from Ajax to controller?
Hello.
Can you please tell me how to pass the value of the variable to the controller from this ajax script?
$(document).ready(function(){
$("#events-select").change(function(){
var month = $("#events-select :selected").val();
$.ajax({
type: "POST",
url: "web/site/events",
data: {"month": month},
cache: false,
success: function(response){
$(".events").html(response);
}
});
});
});
public function actionEvents()
{
if (isset($_POST)){
$meet = $_POST['month'];
}
return $this->render('events');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question