小小API是一个稳定 快速 的 API 接口服务 点击加入QQ群
< !--导入JQ -->
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
<script>
$.ajax({
url: 'https://v2.api-m.com/api/weather?city=枣庄滕州',
type: 'get',
beforeSend: function () {
//请求中执行的代码
},
complete: function () {
//请求完成执行的代码
},
error: function () {
//请求成功失败执行的代码
},
success: function (res) {
// 状态码 200 表示请求成功
if (res.code === 200) {
console.log(res)
} else {
console.log(res)
}
}
})
</script>
{
"code": 200,
"msg": "数据请求成功",
"data": {
"city": "滕州市",
"data": [
{
"date": "周六",
"temperature": "4-24℃",
"weather": "多云",
"wind": "北风4-5级",
"air_quality": "轻度"
},
{
"date": "周日",
"temperature": "2-11℃",
"weather": "晴",
"wind": "北风4-5级",
"air_quality": "良"
},
{
"date": "周一",
"temperature": "5-18℃",
"weather": "晴",
"wind": "西南风4-5级",
"air_quality": "良"
},
{
"date": "周二",
"temperature": "10-23℃",
"weather": "多云",
"wind": "南风3-4级",
"air_quality": "良"
},
{
"date": "周三",
"temperature": "5-17℃",
"weather": "多云",
"wind": "东北风3-4级",
"air_quality": "良"
},
{
"date": "周四",
"temperature": "5-12℃",
"weather": "小雨",
"wind": "东风3-4级",
"air_quality": "良"
}
]
}
}