gongpex Posted February 16, 2016 Share Posted February 16, 2016 Hello everyone Today I tried to create ajax shopping cart add use these code: JQuery : $(document).ready(function(){ $("#fm").on('submit',function() { // this code for form var fsb = $(this).serialize(); $.ajax({ type: "POST", url: "<?php echo base_url('index.php/product/add');?>", data : fsb, dataType: "html", success: function(response){ $("#cart-info").html(response); } }); }); }); this my php code on controller(using Code Igniter) function add() { $id = $this->input->post('product_code'); $this->db->where('product_id',$id); $query = $this->db->get('product'); $stock = $query->row()->stock; echo $stock; // show stock of product } this on views : <div id="cart-info">This code supposed changed when user submit form on above</div> <form id="fm"> <input type="text" name="product_code" value="<?php echo "A100";?>" /> <!-- this code for product id --> <button>TEST</button> </form> My purpose is to show product stock on "cart-info" when user submitted this form. This code works properly on chrome and IE but didn't work on Opera and Firefox, Q : What mistake on my code? please help Thanks Link to comment Share on other sites More sharing options...
dsonesuk Posted February 16, 2016 Share Posted February 16, 2016 Add attribute 'type' with value 'submit' and see if that helps. Link to comment Share on other sites More sharing options...
Chikwado Posted March 7, 2016 Share Posted March 7, 2016 (edited) <button type="button" id="button">[]</button> $("#button").on("click", function(){ Edited March 7, 2016 by Chikwado Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now