-
Simple Ajax
Hallo zusammen,
ich hab grade ein Brett vorm Kopf.
Will mit Simple Ajax Daten aktualisieren. Folgenden Code habe ich.
config.php
PHP-Code:
$GLOBALS['TL_HOOKS']['simpleAjaxFronted'][] = array('Spelling', 'testAlex');
Spelling.php
PHP-Code:
class Spelling
{
public function testAlex()
{
if ('myrequest' === Input::get('acid')) {
$return = ['foo', 'bar', 'foobar'];
header('Content-Type: application/json');
echo json_encode($return);
exit;
}
}
}
JavaScript Code
HTML-Code:
(function ($) {
$(document).ready(function () {
$('#spellit').click(function () {
$.ajax({
type: "GET",
url: "SimpleAjaxFrontend.php",
data: {
acid: "myrequest"
},
success: function (result) {
alert('test');
}
});
});
});
})(jQuery);
Wenn der Prozess fertig ist, sollte die Meldung "test" kommen. Leider erhalte ich diese Meldung nicht.
Hab auch schon mit POST und GET versucht.
Was stimmt bei meinem Code nicht?
-
In deiner config.php hast du simpleAjaxFronted statt simpleAjaxFrontend geschrieben.
-
Danke dir.
Blöd wenn man die Sachen kopiert und nicht nachschaut.
https://github.com/richardhj/contao-...er-hook-legacy