![]() |
How to get the ajax post value (json) via jquery in controller function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: How to get the ajax post value (json) via jquery in controller function (/showthread.php?tid=44962) |
How to get the ajax post value (json) via jquery in controller function - El Forum - 09-02-2011 [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... |