异步请求ddh,使用post请求,参数path=‘/data/home’
var url = 'https://www.ddh.com' var path = '/data/home' function ajax(url, path, method) { return new Promise(function(resolve, reject) { var xhr = new XMLHttpRequest() xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if (xhr.status === 200) { resolve(xhr.responseText) } else { reject(xhr.status) } } } xhr.open(method, url + path, true) xhr.send() }) } ajax(url, path, 'post').then(function(data) { console.log(data) }, function(error) { console.log(error) })