Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我的joomla模块中不能使用ajax_Ajax_Joomla_Joomla2.5 - Fatal编程技术网

我的joomla模块中不能使用ajax

我的joomla模块中不能使用ajax,ajax,joomla,joomla2.5,Ajax,Joomla,Joomla2.5,我对joomla开发非常陌生,我正在学习如何在新创建的模块中使用AJAX功能的教程 基本上,在我的tmpl/default.php中,我有: <script> function runButton() { alert("clicked"); var url='http://127.0.0.1:4444/getData'; var request = new Request({ url: url, me

我对joomla开发非常陌生,我正在学习如何在新创建的模块中使用AJAX功能的教程

基本上,在我的tmpl/default.php中,我有:

<script>
function runButton() {
  alert("clicked");
  var url='http://127.0.0.1:4444/getData';
  var request = new Request({
                  url: url,
                  method:'get',
                  onSuccess: function(responseText){
                    document.getElementById('fields-container').innerHTML=  responseText;
                  }
                }).send();
</script>
<?php
  defined('_JEXEC') or die('Restricted access');
?>
<input type="button" value="Click Here for Ajax Call" onClick="runButton()",1000);"/>
  <div id="fields-container">
</div>
侦听端口4444的进程是一个代理,它将从我的模块中启用跨域ajax调用。如果我指定'http://localhost:4444/getData"

有什么想法吗

更新

这似乎与未启用跨端口http查询(即使在同一主机上)有关。任何解决方法?

您正在使用
定义('u-JEXEC')或die('Restricted access')通常限制ajax

如果还没有,则需要使用
define(“'u-JEXEC',1”)

请注意,您需要使用define,而不是defined


另外,请确保在ajax脚本之前先使用此代码。

我已经更改了我的代码,使其使用define(“'u-JEXEC',1”),但这仍然是一样的。define('u-JEXEC',1)不利于模块中的安全性。它允许人们使用此文件作为joomla的替代入口点。对于ajax,您应该参考helper.php文件中的函数!!您将使用哪个URL直接引用模块的helper.php中的函数?是否需要为此模块创建控制器?
OPTIONS http://127.0.0.1:4444/getData Resource failed to load