var url = 'http://irun-dev.hupu.com/matchWeb/matchInfo?match_id=79';
// 用fetch方法
/*
var fet = fetch(url).then(function(data){
console.log('done...');
if(data.ok){
return data.json();
}
}).catch(function(error){
console.log('error...');
});
fet.then(function(obj){
console.log(obj);
console.log(obj.result.matchInfo.fee_goods_id);
}).catch(function(error){
console.log(error);
});
*/
console.log('------------------------------------------------------------------------');
// 用XMLHttpRequest方法
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = function(data){
console.log('done...');
console.log(data);
if(data.currentTarget.readyState === 4){
if(data.currentTarget.responseText !== ''){
console.log('done again...');
var obj = JSON.parse(data.currentTarget.responseText);
console.log(obj);
console.log(obj.result.matchInfo.fee_goods_id);
}
}
};
xhr.onerror = function(data){
console.log('error...');
console.log(error);
};
xhr.send();