interface Config{
type: string;
url: string;
data?:string;
dataType:string;
}
function ajax(config: Config){
var xhr = new XMLHttpRequet();
xhr.open(config.type, config.url, true);
xhr.send(config.data);
xhr.onreadystatechange = function (){
if(xhr.readyState == 4 && xhr.status == 200){
console.log('success')
}
}
}
ajax({
type: 'get',
url: 'https://www.baidu.com',
dataType: 'json'
})
ts接口ajax请求实例
最新推荐文章于 2024-05-28 16:48:19 发布