First, I would like to thank all the answers. Actually it was a couple of errors, First : as @bipen said, the data should be sent as an object, not a string. and when I tried this, it did not work because I did not put a single quote around the data
$.ajax({ url: url, type: 'POST', contentType: 'application/json', data: {'data': data} });
Second : as @foxmulder said, contentType has been sealed and should have ContentType so the correct code:
$.ajax({ url: url, type: 'POST', ContentType: 'application/json', data: {'data': data} }).done(function(response){ alert('success'); }).fail(function(jqXHR, textStatus, errorThrown){ alert('FAILED! ERROR: ' + errorThrown); });
and just FYI, if someone had trouble extracting PHP, here's how to do it:
$data = $this->input->post('data'); $data = json_decode($data); $sum = $data->sum; $info_obj = $data->info; $item_qty = $info_obj[0]->quantity;
source share