Please, explain to me how to run snippet CookieList with ajax?
I tried next:
1. Created snippet ajaxCookieList:
<?php
if (isset($_POST["action"])) {
$values = $modx->runSnippet('addToCookieLIst',array(
'value' => $_POST['action']
));
$output = $modx->runSnippet('pdoResources',[
'parents' => 6,
'resources' => $values,
'tpl' => 'popup.favorites.item',
'includeTVs' => 'header.bgImage,franchise.logo,franchise.price,title,subtitle',
'prepareTVs' => '1',
'hideContainers' => '1'
]);
return $output;
}
Then i created chunk with this code:
<script> jQuery(function($){ $('a.franchise-pin, a.franchise-favorite-add').click(function(e){ var value = $(this).data('value'); $.post(document.location.href, {action: value}, function(data) { $('#favorites').html(data); $('#favorites').modal('show'); }); e.preventDefault(); }); }); </script>
But response is all page..
What is wrong?