I have the same problem and I am getting frustrated. I tried all the ways you said but I still get the value in the empty controller.
please help me!
$(document).ready(function(){
$('button').click(function() {
$.ajax({
url: "http://localhost:4499/Avayar2/public/index.php/Home/testakk/",
type: 'post',
headers: {'X-Requested-With': 'XMLHttpRequest'},
dataType: 'json' ,
data: {
toto: 'dibd',
koko: 'qqqq'
},
success: function(data2) {
alert(data2.sdf)
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(xhr.responseText);
}
}); //end ajax
});
});