admin管理员组文章数量:1313001
i am trying to add auto load contents to my existing module by using joomla ajax-com . the module display videos on the page , it is not has pagination .
i created a helper file in the root of the module like this : mod_mymodulename/helper.php
i added in the helper.php a function like this : static function getDataAjax() { my code}
i added it in the xml file like this :
<filename>helper.php</filename>
under <files>
i added in tmpl/default.php js code like this : (this is a part of the code ) on button click
url: 'index.php?option=com_ajax&module=mod_mymodulename&method=getData&format=json',
on the site i get this error message :
the method getDataAjax not found
where is my fault ? why the code cant find the getDataAjax ?
the getDataAjax is there in helper.php .
update :
i noticed that this code is fore joomla 3 ::
<script>
function load_videos() {
let nusers = document.querySelector('.load-more-videos');
Joomla.request({
url: 'index.php?option=com_ajax&module=mymodulename&method=getData&format=json',
method: 'GET',
onSuccess(data) {
const response = JSON.parse(data);
if (response.success) {
nusers.innerHTML = response.data;
} else {
const messages = {"error": [response.message]};
Joomla.renderMessages(messages);
}
},
onError(xhr) {
Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr));
const response = JSON.parse(xhr.response);
Joomla.renderMessages({"error": [response.message]}, undefined, true);
}
});
}
</script>
anybody can address me where can i find the right info about com-ajax for joomla 5 ?
i searched google , i found only for j3 and j4 .
本文标签: joomla 5issue on adding ajax on module using AjaxcomStack Overflow
版权声明:本文标题:joomla 5 - issue on adding ajax on module using Ajax-com - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741895658a2403560.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论