Failed PHP AJAX loading

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');} ?>
<?php if(!kirby()->request()->ajax()) { snippet('footer'); } ?>


function test() {
		url: 'ajax',
		success : function(data) {        


Do I see this right that you put the php file into the content folder? You can’t do this, your php file needs to go into the site/templates folder.

This makes sense!!! And fixed it. Thanks !! I guess it was too late yesterday :smiley: