I am a beginner of PHP. I am trying use Codeigniter to implement a simple shopping cart, but I got stuck by a problem: I wanna update cart content, but I don't know how to retrieve data from client side, the data describes several pair of rowid and quantity of product.
My code is as following:
javascript:
$(document).ready( function(){
$("#btn .update").click(function(){
var cell;
var data = [];
var rowNo = document.getElementsByTagName("tr").length -2; // exclude head and bottom
var i;
for(i = 1; i <= rowNo; i++){
data[i-1] = [];
cell = document.getElementsByName(i+"[rowid]");
data[i-1][0] = cell[0].value; //rowid
cell = document.getElementsByName(i+"[qty]");
data[i-1][1] = cell[0].value; //quantity
}
$.post('http://localhost/CodeIgniter/shopping_cart/update_cart', data, function()
{
return false;
});
});
});
shopping_cart.php:
function update_cart(){
$data = $this->input->post();
}
I couldn't get any data from post. Is there any other way I can retrieve the data or implement this function?