I want to get a cascading dropdown in pyrocms. I wrote the following ajax code. But it always displays dialog alert(error). That is ajax request is failing.
<script type="text/javascript">
$(document).ready(function() {
$('#vehicle_cat_id').change(function() { //any select change on the dropdown with id country trigger this code
//$("#cities > option").remove(); //first of all clear select items
var cat_id = $('select#vehicle_cat_id').val(); // here we are taking country id of the selected one.
//alert(cat_id);
$.ajax({
type: "POST",
url: "<?= base_url('admin/vehicle/modellists') ?>", //here we are calling our user controller and get_cities method with the country_id
data: 'cat_id = '+cat_id,
success: function(html)
{
//alert('test');
$('select#vehicle_model_id').html(html);
},
error: function(){
alert('failed');
}
});
});
});
</script>
What have i done wrong?