相互关联的下拉列表无效

时间:2016-07-29 09:31:15

标签: php jquery ajax

我正在处理相互关联的下拉列表,即选择一个下拉列表ajax调用生成并填充另一个下拉列表,依此类推。

所以我的问题是来自服务器端的数据,在选择每个下拉列表时我也希望过滤可用结果,但来自服务器端的数据会附加到show div,即{{1我想只追加dropdown-list items and results-items 客户端代码

results-items to show div

服务器端代码

        var country_code = $(this).val();
    console.log(country_code);
    if(country_code){
         $('#loadingmessage').show(); 
        $.ajax({
            type:'POST',
            url:'dependent.php',
            data:'country_code='+country_code,
            success:function(html){
                console.log(html);
                $('#state').html(html);
                $('#city').html('<option value="">Select state first</option>'); 
                $('#results').html(html);
                $('#loadingmessage').hide();
            }
        }); 
    }else{
        $('#state').html('<option value="">Select country first</option>');
        $('#city').html('<option value="">Select state first</option>'); 
    }
});

0 个答案:

没有答案