JSON和AJAX

 

AJAX基础语法:

        var xhr = new XMLHttpRequest()
        xhr.open('GET','URL',true)
        xhr.send()
        xhr.onreadystatechange == function(){
            if(xhr.readyState == 4 && xhr.status == 200){
                var reasult = xhr.response
                var arr = JSON.parse(reasult)
                console.log(arr)
            }
        }

 

JSON.parse()//解析成对象格式

JSON.sringify()//序列化成字符串

posted @ 2020-11-17 17:21  Treee  阅读(55)  评论(0)    收藏  举报