Hey any example with Ajax and Cake 3.5 ?
I create a method in Controller, and in index.ctp a button and associate js script, with this code:
(document).on('click','#btn',function(e){
.ajax({
url : ‘http://localhost:8765’ +’/Pages/ajaxTeste’,
type:‘POST’,
dataType:‘JSON’,
success:function(d){
html += “Lorem ipsum”;
$(’#p’).html(html);
console.log(“text”);
},
error:function(xhr, e, etype){
if(console){
console.log(xhr);
console.log(e);
console.log(etype);
}
}
})
});
And I can’t set this text to
…Problem seems a parsererror… But I cant figure out…