使用Ajax查询的Joomla组件开发 [英] joomla component development with Ajax queries

查看:214
本文介绍了使用Ajax查询的Joomla组件开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用AJAX查询的PHP脚本,但我希望他们能够的Joomla的(2.5)框架的框架下进行操作,所以我可以有会话ID的,用户ID等提供给我。

I have a PHP script used for AJAX queries, but I want them to be able to operate under the umbrella of Joomla's (2.5) framework so I can have session id's, user id's etc available to me.

例如:

$(function () {
 $.ajax({                                     
   url: 'ajax.php',   //the script to call to get data                     
   dataType: 'json'        //data format     
   ...
 });
}); 

在哪里ajax.php有code,如:

Where ajax.php has code such as:

$user =& JFactory::getUser();

据我所知这是最好的让你的AJAX / JSON调用一个标准的Joomla组件。我不知道很多关于发展的MVC组成部分,但是从我所看到的却是矫枉过正的方式为我想做的事情。

From what I understand it's best to make your AJAX/JSON calls to a standard Joomla component. I don't know much about developing a MVC component but from what I can see it is way overkill for what I want to do.

有没有别的东西,我可以用?

Is there something else I could be using?

推荐答案

如果您创建一个组件,您可以创建新的视图对原材料查询,例如元件库/ com_yourcomponent /视图/ AJAX / view.raw.php ,并把所有的逻辑和输出在那里 网址为的index.php选项= com_yourcomponent和放大器;查看= AJAX和放大器;格式=原

if you create a component you can create new view for raw queries for example compoments/com_yourcomponent/views/ajax/view.raw.php and put all logic and output in there url will be index.php?option=com_yourcomponent&view=ajax&format=raw

您可以用创建 Controller.php这样新的方法退出()打印信息和网址后,将的index.php选项= com_yourcomponent和放大器;任务= AJAX

you can to create new method in controller.php with exit() after print information and url will be index.php?option=com_yourcomponent&task=ajax

这篇关于使用Ajax查询的Joomla组件开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆