$.post
是采用了 POST 方式请求接口。
格式如下
$.post( url, [, data] [, callback] [, type])
参数名称 | 类型 | 说明 |
---|---|---|
url | String | 请求 HTML 页面的 URL 地址 |
data(可选) | Object | 发送至服务器的 key/value 数据 |
callback(可选) | Function | 回调函数,只有当请求成功才执行! |
type(可选) | String | 服务器返回的数据格式,包括 xml/html/json/text 等 |
<html>
<head>
<title>example</title>
<meta charset="utf-8"/>
</head>
<body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
<script>
$(function () {
$.post("https://clwy.cn/oauth/token", {
grant_type: 'password',
client_id: 'RCnGmwJv15EIuTT9tH0VU5LR4XnfTHLS1EZ32svVmEc',
client_secret: 'oQYcSZ6lbGSk-EusazGBdb7_4e8v2TAWBn9vVmmkD6k',
username: '你的账号',
password: '你的密码'
}, function (data) {
console.log(data)
}, "json")
});
</script>
</body>
</html>
已添加到喜欢了