[eluser]bsrbvr[/eluser]
Hi,
I am using codeigniter 2.1.0 and php 5.3.5.
I am trying to get the data entered in textbox after submitting using Ajax. But I am not able to get any alert message.
My view page:
<input type="text" id="txtLocation" name="txtLocation" class="tb1"></input>
<input type="image" name="myclicker" src="<?base_url()?>images/search_button.png" id="offersearch" />
[removed]
$(document).ready(function(){
$('#offersearch').click(function () {
var msg = $("#txtLocation").val();
$.post("/location_ctrl/getLatLong", { 'item': msg },
function(data){
alert(data.result);
}, "json");
});
});
[removed]
location_ctrl.php page:
class Location_ctrl extends CI_Controller{
public function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->model('offerModel');
}
public function getLatLong()
{
$place = trim($this->input->post('item'));
$array = array('result' => $place);
header('Content-Type: application/json',true);
echo json_encode($array);
}
}
Where is the problem coming here.
Thanks.