Jump to content

jquery ajax works on chrome and IE but doesn't work on firefox and opera


gongpex

Recommended Posts

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

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...