-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[4.x][com_ajax] Ajax call error from the module #37012
Copy link
Copy link
Open
Labels
Description
Ajax is not available by namespace!
Steps to reproduce the issue
Namespace from install xml
<namespace path="src">Am\Module\Amap</namespace>
...
js
Joomla.request({
url: "index.php?option=com_ajax&module=amap&method=getReloadLayoutParams&format=json",
method: "POST",
headers: {
"Cache-Control" : "no-cache",
"Content-Type" : "application/json"
},
onBefore: function (xhr){
console.log("onBefore");
},
onSuccess: function (response, xhr){
if (response !== ""){
let res = JSON.parse(response);
console.log(res.message);
}
console.log("onSuccess");
},
onError: function(xhr){
console.log("onError");
},
onComplete: function (xhr){
console.log("onComplete");
}
});
AmapHelper.php
path 'modules/mod_amap/src/Helper/AmapHelper.php'
<?php
namespace Am\Module\AMAP\Site\Helper;
\defined( '_JEXEC' ) or die;
class AmapHelper
{
public static function getReloadLayoutParamsAjax()
{
$html = array();
$html['success'] = true;
$html['message'] = 'Ok';
$html['messages'] = '';
$html['data'] = array();
echo json_encode($html);
exit;
}
}
Expected result
JSON data
Actual result
Console log
onBefore
File mod_amap/helper.php does not exist. // ??? It doesn't exist anyway
onSuccess
onComplete
System information (as much as possible)
Joomla v. 4.1.0-rc4
PHP 7.4.27
Reactions are currently unavailable