标签:ajax html node script type span pre load class
<script> function ajaxFn(url, HTMLNode) { $.ajax({ type: ‘GET‘, url: url, data: {}, dataType: ‘json‘, success: function(result) { var html = ""; for(var i = 0; i < 5; i++) { console.log(result[i].name); html += (‘<li>‘+result[i].name+‘</li>‘) } $(HTMLNode).html(html) }, error: function() { console.log("数据请求失败"); } }) } window.onload = function() { ajaxFn(‘/ganController/xuanhuan.action‘, "#init ul"); } </script>
后端要把集合转换成json格式。
在这里感谢明月大佬(qq185617705)不厌其烦指教。
标签:ajax html node script type span pre load class
原文地址:http://www.cnblogs.com/suiyisuixing/p/7360627.html