如何使用jQuery阿贾克斯的Joomla组件? [英] how to use Jquery AJAX in Joomla Components?
问题描述
即时通讯发展的网站上的Joomla,同时,我停留在一个问题,请大家帮我在下面的问题
i m developing site in Joomla, meanwhile i stuck in a problem,please help me in below problem
这是我的组件文件夹结构
here is my folder structure for component
htdocs/Joomla/administrator/component/com_test/test.php,controller.php
models/test.php
controllers/test.php
views/test/view.html.php
view/test/tmpl/default.php
现在 view.html.php
我在哪里即时通讯使用的一种形式的 jQuery的阿贾克斯$ C $下usernmae可用性检查
now in view.html.php
i created a form where i m using jquery ajax code for usernmae availability check
但我不是让我怎么把所有的东西拿到结果USENAME是否可用。
but i m not getting how do i combine all things to get the result that usename is available or not
这是我的code写的测试/ view.html.php
here is my code written on test/view.html.php
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#username").change(function () {
var usr = jQuery("#username").val();
if (usr.length >= 2) {
jQuery("#status").html('<img src="loader.gif" align="absmiddle"> Checking availability...');
jQuery.ajax({
type: "POST",
url: "index.php?option=com_test&view=check_user",
data: "username=" + usr,
success: function (msg) {
jQuery("#status").ajaxComplete(function (event, request, settings) {
if (msg == 'OK') {
jQuery("#username").removeClass('object_error'); // if necessary
jQuery("#username").addClass("object_ok");
}
else {
jQuery("#username").removeClass('object_ok'); // if necessary
jQuery("#username").addClass("object_error");
jQuery(this).html(msg);
}
});
}
});
}
});
<script>
<form action="" method="post" name="addUserForm" id="addUserForm" >
<table width="100%" border="0" cellpadding="4" cellspacing="2">
<tr>
<th >User Name :</th>
<td ><input type="text" name="username" id="username" size="50">
<span id="status"></span>
</td>
</tr>
</table>
</form>
我已创建以下文件夹结构,上述动作,请告诉我,我在哪里弄错
i have created below folders structure for above action , please tell me where do i mistake
view/check_user/view.html.php
views/check_user/tmpl/default.php
code中的 check_user / view.html.php
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.view');
/**
* HTML View class for the advertising component
*/
class TestViewCheck_user extends JView
{
/**
* Default display function
*/
function display($tpl = null)
{
$testController = new TestController();
// Make an object of Main Model class contains Main functions
$testModel = $testController->getModel('test');
$userName = JRequest::getVar('username');
parent::display($tpl);
}
}
?>
但是当我运行此code ...为什么
的http://localhost/Joomla/includes/js/joomla.javascript.js
文件运行无限次......终于得到4误差
but when i run this code...why
http://localhost/Joomla/includes/js/joomla.javascript.js
file runs infinite times.. and finally give 4 error
现在我要修改/添加更多的???请大家指导我....
now what i have to modify/add more??? please just guide me ....
指该教创造一步一步成分任何有用的链接...这将是对我来说非常有帮助的。
refer any useful link which teach to create component step by step ...it will be very helpful for me
多谢
推荐答案
所有前端code应该在你的TMPL,让你的Ajax的东西应该在那里了。检查本教程就如何使MVC组件为Joomla http://www.joomladevuser.com/tutorials/components 。
All front end code should be in your tmpl, so your Ajax stuff should be in there too. Check this tutorial out on how to make MVC components for Joomla http://www.joomladevuser.com/tutorials/components.
这篇关于如何使用jQuery阿贾克斯的Joomla组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!