每次使用ajax -post()从数据库获取Json数据都是不同的(变为double)

时间:2016-03-15 12:52:59

标签: jquery ajax

<script type="text/javascript">
    function getReady(){
        $('.selectpicker').empty(); //clear the select
            $.ajax({
                type : "POST", 
                contentType : "application/json", 
                url : "/btlocationServer/GetBeaconInfo", 
                dataType : 'json',
                cache:false,
                success : function(data){
                    $.each(data, function(i, item) {
                        $('.selectpicker').append("<option >"+item.name+"--"+item.address+"</option>");   //append data to option of select
                        console.log(item.name+"--"+item.address);//log data
                    });
                    $('.selectpicker').selectpicker('refresh')
                }
            });
    }
</script>

这是我第一次启动服务器

first

第二次刷新页面时:

second

每次刷新页面时,数据都会变成双倍。

所以我该怎么处理呢

0 个答案:

没有答案