如何使用阿里云api接口

学习分享1年前 (2023)更新 bestcyt
181 0 0

test:天气预报接口
如何使用阿里云api接口
那么,我要如何发送ajax请求该接口呢?

$.ajax({
	// type:"GET",
	url:"http://ali-weather.showapi.com/day15?",
	/*
	 * beforeSend在提交时重新定义head头文
	 * 格式为
	 * request.setRequestHeader("Authorization", "APPCODE " + "e8444b54ae4b465781f8bee5dd8ff2cd");
	 * 注意appcode后有空格,不能去掉
	 */
	beforeSend:function(request) {
		request.setRequestHeader("Authorization", "APPCODE " + "e8444b54ae4b465781f8bee5dd8ff2cd");
	},
	data:{
		"area":"兰考"
	},
	dataType:"json",
	success:function(data){
		console.log('88');
		console.log(data);
	}
});

打印请求结果:十五条数据
如何使用阿里云api接口
 
 

© 版权声明

相关文章