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. 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
. But firebug is giving me this error
ERROR: JSON.parse: unexpected character
and as I'm looking in the data it is returning a whole html code.
I solved this by connecting my module with the component following this tutorial http://forum.joomla.org/viewtopic.php?p=2424982