Hello I am trying to load a php snippet with ajax to my html file. I went to every other ajax related topic here, but nothing seems to work for me. For some reason ajax loads the complete code as a text of my homepage into the div and not the content from the ajax.php file.
my code looks like this:
ajax.php (in content/ajax
<?php if(!kirby()->request()->ajax()) { snippet('header');} ?>
<p>test</p>
<?php if(!kirby()->request()->ajax()) { snippet('footer'); } ?>
ajax
function test() {
$.ajax({
url: 'ajax',
success : function(data) {
console.log(data);
$('#time').text(data);
}
});
}
test();