お互いに応じて、1つのクラスに3つのドロップダウンがあるモジュールがあります。MySQLからデータをロードする最初のドロップダウンがあります。最初に選択した値に応じて、2番目のデータをロードしてほしい。現在私はこのコードを持っています:
<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>
これはに適用され、default.php
高さが設定されている場合は実行され、別のクラスからのMySQLステートメントが正常に機能し、それをにエンコードしjson
ます。しかし、firebugは私にこのエラーを与えています
エラー:JSON.parse:予期しない文字
データを調べていると、HTMLコード全体が返されます。