ajax获取后台数据

323 阅读1分钟
<script>
    $(function(){
        $.ajax({
            url:"http://localhost:3000/tag",
            type:"GET",
            success:function(res){
                if(res.status==200){
                const data =  res.data;
                let html="";
                for (let index = 0; index < data.length; index++) {
                    const element = data[index];
                   html+=  element.text+"&nbsp;&nbsp;";
                }
                $(".col-xs-12").html(html);

                }
            },
            error:function(err){
                console.log(err);
            }
        })
    })
</script>