Could someone figure out why every ajax call is leading to error. Here goes my problem.
The code is
$(document).ready(function(){
$('#officer-id').change(function(){
var officer_id = $('#officer-id').val();
$.ajax({
type:'POST',
url:"<?=base_url()?>" + "Home/ajax_view",
dataType: 'json',
data:{'officer_id':officer_id},
success:function(data){
alert(this.data );
},
error:function(data){
alert("error");
}
});
});
});
the Id officer_id in the html code is
<select id="officer-id" placeholder="Choose an officer">
<option value=ab1>ab1</option><option value=ab2>ab2</option><option value=rep1>rep1</option>
</select>
the url:"<?=base_url()?>" + "Home/ajax_view"
content
public function ajax_view(){
return ;
}
Why my code is not executing success inspite of getting no error in console