简体   繁体   English

如何在joomla 1.5的模块中使用ajax jquery

[英]How to use ajax jquery in module of joomla 1.5

I have a struct folder: 我有一个struct文件夹:

modules/mod_test/tmpl/default.php
modules/mod_test/tmpl/nation.php
modules/mod_test/helper.php
modules/mod_test/mod_test.php
modules/mod_test/mod_test.xml

in default.php I am using: 在default.php中,我正在使用:

<script type="text/javascript">
$(document).ready(function(){
   $('.nation').change(function(){
        var id = $(this).val();
        var dataString = 'id='+id;
        var url = 'modules/mod_test/tmpl/nation.php?'+dataString;
        $.getJSON(url + '&jsoncallback=?', function(data){
            $('.city').html(data);
        })
        return false;
   }); 
});
</script>

I has created nation.php in folder modules/mod_test/tmpl/ ? 我在文件夹模块/ mod_test / tmpl /中创建了national.php? That right put in joomla ? 那权利放进joomla了吗? And if right, How to call connect database in city.php that use ? 如果正确,如何在使用的city.php中调用connect数据库? How to ideas 如何思考

i guess you dont need '&jsoncallback=?' 我猜你不需要'&jsoncallback=?' the function itself is callback function 该函数本身是回调函数

$.getJSON(url, function(data){
         $('.city').html(data);
  })

This is internally equivalent to 在内部相当于

$.ajax({
  url: "url",
  dataType: 'json',
  success: function(data){
   $('.city').html(data);
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM