[eluser]Unknown[/eluser]
simple method to get posted value is by $this->input->post
but is not working for me here is the issue..
jquery ajax call:
var selected_brand = $(curr).attr("value");
var urlpath = "<?php echo $base_url; ?>/index.php/tyre_sale/GetItemsByBrand";
var odata = "'data' : '" + selected_brand + "'"; // data : 2
odata = '{' + odata + '}';
var optionlist = "";
$.ajax({
type : "POST",
url : urlpath,
data : odata,
contentType: "application/json; charset=utf-8",
dataType: "json",
POST caught at firebug
JSON
data "2"
Source
{'data' : '2'}
which mean the ajax data is being passed in json correctly
now i want to get this '2' however ... $this->input->post('data') and $_POST['data'] both not working... here is my controller function
$brand = $this->input->post('data');
echo 'data is : '. $brand.'.<br/>';
//$brand = $this->input->post('data');
$items = $this->Model_sales->GetItems($brand)
if ( $items == "" || ! isset ( $items ) ) { return; }
echo json_encode($items);
getting null / empty in $brands...