I’m a beginner in Yii framework.
I have to create a cascading dropdown fetching data from MySQl database and populating it in the dropdown.
I have two such jQuery Ajax functions to post data and get results back.
Dropdown 1 is a pure HTML dropdown which gets populated by data from backend and displays it successfully.
But, second dropdown is a PHP dropdlist created by Yii in _form.php
<?php echo $form->dropDownList($model,'groupZCode',array(); ?>
For this I’m using jQuery Ajax function :
<script>
$("#builder_group").change(function(){
console.log("Hello 1");
$('#Ivrmapping_groupZCode').find('option').remove().end(); //clear the city ddl
var builder = $(this).find("option:selected").text();
alert(builder);
//do the ajax call
$.ajax({
url:'getGroupzCode.php'
type:'GET',
data:{city:builder},
dataType:'json',
cache:false,
success: function(data) {
// Call this function on success
console.log(data);
var yourArray = JSON.parse(data);
console.log(yourArray);
$.each(yourArray, function (index, yourArray) {
);
});
},
error: function() {
displayDialogBox('Error', err.toString());
}
});
});
});
</script>
But this is not working