[英]Joomla module and Jquery
I have a module with three drop-downs, in one class, depending on each other. 我在一个类中有一个包含三个下拉菜单的模块,这取决于彼此。 I have the first drop-down that loads the data from MySQL. 我有第一个下拉菜单,用于从MySQL加载数据。 I would like that the second one loads the data depending on the first selected value. 我希望第二个根据第一个选定的值加载数据。 Currently I have this code: 目前,我有以下代码:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function curPageURL() {
var pathname = window.location.pathname;
return pathname;
}
$(document).ready(function(){
$('#art1').change(function(){
var $height = $('#art2') ;
$height.find('option:not([value=default])').remove();
$.getJSON(curPageURL(), {height:$(this).val()}, function(heights){
$.each(heights, function(index, height){
$height.append('<option value="'+height[0]+'">'+height[1]+'</option>');
});
});
});
});
</script>
This goes in the default.php
and if height is set it executes and MySQL statement from another class which works fine and then encodes it to json
. 这在default.php
,如果设置了height,它将执行并且从另一个运行良好的类的MySQL语句执行,然后将其编码为json
。 But firebug is giving me this error 但是萤火虫给了我这个错误
ERROR: JSON.parse: unexpected character 错误:JSON.parse:意外字符
and as I'm looking in the data it is returning a whole html code. 当我查看数据时,它返回的是整个html代码。
我通过按照本教程http://forum.joomla.org/viewtopic.php?p=2424982连接模块和组件来解决此问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.