简单ajax交互

来源:互联网 发布:上海软件开发培训班 编辑:程序博客网 时间:2024/06/07 08:56
var json={        "code": 0,        "msg": "",        "detailMsg": "",        "data": {            "list": [{                "date": "2017-09-14 17:34:31",                "price": 0.123311,                "volume": 0.1235,                "type": 0,                "rmb": 0.0152289085            },            {                "date": "2017-09-14 09:56:08",                "price": 5,                "volume": 1,                "type": 1,                "rmb": 5            },            {                "date": "2017-09-07 14:44:26",                "price": 0.071,                "volume": 1,                "type": 0,                "rmb": 0.071            }]        }    }$.ajax({    url: '',    type: 'get',}).then(function(data){    if (json.code==0) {        console.log('成功');        var html='';        var list=json.data.list;        $.each(list,function(i){            // console.log(list[i]);            var listi=list[i];            var date=listi.date;            var price=listi.price;            var volume=listi.volume;            var rmb=listi.rmb;            html+='<ul class="dabox"><li>'+date+'</li><li>'+price+'</li><li>'+volume+'</li><li>'+rmb+'</li></ul>';        });        $('.dabox').html(html);    };},function(error){});