I'm programing on Subrion CMS and I need to do something simple but in Subrion it is a little complicated for me. I want to make a combobox that changes according to the value of another combobox, as it is used in countries and cities. The following code work ok in an admin page, bun in front don´t work. I've the following code: js==
$(document).ready(function () {
//chance cities
$("#state").change(function() {
$("#state option:selected").each(function() {
state_id = $(this).val();
intelli.post(intelli.config.ia_url + 'actions.json', {action: 'get-cities', state_id: state_id},
function (response) {
$("#city").empty();
$("#city").append(new Option('-- select --', 0));
if(response.length > 0){
alert("Response ==> " + response);
}
response.forEach(element => {
$("#city").append(new Option(element.city, element.id));
});
});
});
});
}
php (/front/actions.php)==
case 'get-cities':
if (iaView::REQUEST_JSON == $iaView->getRequestType()) {
$state = $_POST['state_id'];
$cities = [];
if (!empty($state)) {
$cities = $iaDb->assoc('id, city', 'state='.$state, 'city');
$iaView->assign('cities', $cities);
return $cities;
}
}
break;
I debug de php code and consult the cities Ok, but in JS the response is empty