I am new to CI and i am having issues in following code: My Controller shows all the values of countries dynamically from DB, i need to pass value onclicking particular chechbox
HTML
value 1<input type="checkbox" class="chkbox" value="value1"/>
value 2<input type="checkbox" class="chkbox" value="value2"/>
value 3<input type="checkbox" class="chkbox" value="value3"/>
value 4<input type="checkbox" class="chkbox" value="value4"/>
Jquery Ajax
$(document).ready(function(){
$(document).on('click','.chkbox',function(){
var id=this.value;
$.ajax({
type: "POST",
context: "application/json",
data: {id:id},
url: "http://localhost/xyz/index.php/controller_name/function_name",
success: function(msg)
{
alert('result from controller');
}
})
});
});
Controller
public function function_name()
{
$id=$this->input->post('id');
//now use the $id variable for the desired purpose.
}