Hallo liebe Community,
ich teste gerade mit Contao 4.4 die Erweiterung contao-ajax_reload_element. Ich schaffe es allerdings nicht, den Inhalt eines Inhaltselements per Klick nachzuladen. Könnt ihr mir einen Tipp geben?
Mein Script sieht derzeit so aus:
Code:
<script>
$("#myBtn").click(function (event) {
event.preventDefault();
$.ajax({
method: 'POST',
url: location.href,
data: {
ajax_reload_element: element.attr('data-ajax-reload-element'),
element: 'ce::88',
page: <?= $GLOBALS['objPage']->id ?>
}
})
.done(function (response, status, xhr) {
if ('ok' === response.status) {
// Replace the DOM
$('.tnb').replaceWith(response.html);
}
else {
// Reload the page as fallback
location.reload();
}
});
});
</script>
Also mit Klick auf den Button (#myBtn) soll der Inhalt des Inhaltselements mit der ID 88 in das DIV mit der Klasse tnb geladen werden.
Grüße,
Dirk
Lesezeichen