mui.ajax请求实例


得到一个json地址,使用 在线JSON校验格式化工具,我们只需要把刚刚那些数据复制粘贴到我给的这个工具里面,然后点击校验就变整齐了。

<script src="../js/mui.min.js"></script> <script type="text/javascript"> var url = "http://。。/search/get/"; mui.ajax(url,{ data: { 'type': 1, 's': "喜欢你", 'limit': 10 }, dataType:'json',//服务器返回json格式数据 type:'post',//HTTP请求类型 timeout:10000,//超时时间设置为10秒;
success:function(data){ // console.log(JSON.stringify(data)); var songs=data.result.songs; mui.each(songs,function(index,item){ var id = item.id, name = item.album.name, author = item.artists[0].name, picUrl = item.album.picUrl, audio = item.audio; }) },
 error:function(xhr,type,errorThrown){ //异常处理; console.log(type); } }); </script>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM