Welcome Guest, Not a member yet? Register   Sign In
Ajax funcation call
#1

Hi, Need help to resolve ajax call issue
In my view page ( working on codeigniter), there is a dropdown and a div section. Based on dropdown value, data will get change in div section. I am using ajax call ( to call method in controller) to upload data in div tag on dropdown change event. Ajax call working fine on first change event of dropdown but when i select any other value in dropdown, ajax function call is not working ( second select and so on). 
My code is:
VIEW PAGE =>
$(document).ready(function() {
   $("body").on('change','#assettype_id',function(e){    // "assettype_id" is dropdown id
      //e.preventDefault();
       var categoryval = $('#assettype_id :selected').val();
       $.ajax({
                  type: 'POST',
                  cache: false,
                  url: 'http://my_path/index.php/assetcontroller/assignpc/'+ categoryval,  // Based on "categoryval" data will change in div tag 
                  dataType: 'html',
                  success: function(data) {
                  $( "#result" ).load( "http://my_path/index.php/assetcontroller/assignpc/"+ categoryval);  // "result" is div tag id
                  $( "#result" ).html(categoryval);   
   },
});
        return false;
    });
}); 

Why ajax call is not working in dropdown second ( so on) change event? 
Thanks in advance
Reply
#2

My purpose is: i have a view page with two section: section one contains a dropdown and second section is used to load data that comes from a another view based on dropdown's selected value? How to make code for this in codeigniter?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB