json

来源:互联网 发布:羊毛衫工艺软件 编辑:程序博客网 时间:2024/05/16 10:55

json获取数据,并且动态加载js.

<script type="text/javascript">

$(document).ready(function(){
                        $.ajax({
                            type:"GET",
                            url:"http://ip:port/系统域名/json/模型名",
                            dataType:"json",
                            contentType : 'application/json;charset=UTF-8',
                            async:false,
                            timeout:2000,
                            success:function(data) {
                                $("#tableUser>tbody").empty();
                                var strResult = "";
                                if(data!=null&&data!=""){
                                        for(var i=0;i<data.items.length;i++){
                                        var users = data.items[i];
                                        strResult +="<tr>";
                                        strResult+="<td>"+users.username+"</td>";
                                        strResult+="<td class='center'>"+users.registerDate+"</td>";
                                        strResult+="<td class='center'>"+users.email+"</td>";
                                        strResult+="<td></td>";
                                        strResult+="<td><a class='btn btn-success' href='#'>"+
                                                    "<i class='glyphicon glyphicon-zoom-in icon-white'></i>View"+
                                                    "</a></td>";
                                        strResult +="</tr>";
                                        $("#tableUser>tbody").append(strResult);
                                        strResult ="";
                                    }  
                                }
                               
                               

                            },
                            error : function() {
                                //alert();
                                alert("error.");
                            }  
                    });        
                       
    })

json获取数据,并且动态加载js.

</script>

<!-- application script for Charisma demo -->
<script src="js/charisma.js" async=false></script>

要点:设置ajax同步,设置要加载的js同步。

0 0
原创粉丝点击