服务器返回格式
{ "code": "1001", "message": "查询成功", "data": [ { "ad_id": "3", "name": "wap首页主广告1", "image": "http://www.xxx.com/data/afficheimg/1440434742398149569.jpg" }, { "ad_id": "4", "name": "wap首页主广告2", "image": "http://www.xxx.com/data/afficheimg/1440434755442738492.jpg" } ] }
html部分
<script type="text/javascript" charset="utf-8"> mui.init(); mui.plusReady(function() { mui.ajax('http://apptest.test.com', { dataType:'json',//服务器返回json格式数据 type:'post', success: function(result) { var vData = JSON.stringify(result); res_data =(new Function("","return "+vData))(); for(var i=0;i<res_data.data.length;i++){ alert(res_data.data[i].name); } }, error: function() { alert('error'); } }); }); </script>