I have a list of links to articles from my blog that dynamically load a json representation of my articles.
For some reason my AJAX only seems to load the first page in my articles.
This is my html
<a class="load-article" href="<?= $article->url() ?>" data-page="<?= $article->url() ?>">
<h3 ><?php echo html($article->title()) ?></h3>
</a>
This is my JSON
<?php
$html = '';
$html .= snippet('article', array('article' => $page), true);
echo json_encode($html);
?>
And this is the AJAX
$(function(){
var element = $('.load-article');
var url = element.data('page') + '.json';
var target = $('.article-container');
$('.load-article').on('click', function(e) {
e.preventDefault();
$.get(url, function(data) {
$(target).append(data);
});
});
}),