could figure out why every ajax call leading error. here goes 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 html code is
<select id="officer-id" placeholder="choose 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 code not executing success inspite of getting no error in console
try this:
$('#officer-id').change(function(){ var officer_id; if(officer_id = $(this).val()){ // $.ajax({ type:'post', url:"http://62.231.118.52:9080/teste/random_test/form_validate.php", datatype: 'json', data:{'officer_id':officer_id}, success:function(data){ alert(this.data ); }, error:function(data){ alert("error"); } }); } });
Comments
Post a Comment