代码如下,success获取不到返回值
var data;
var grant_type = "client_credentials";
var client_id = "rlVkXeUg6L6hVbKwBygKEq6D";//必须参数,应用的API Key;
var client_secret = "cto5Hj1ZBLUISl6os8kqiasv7sP6YQBD";//必须参数,应用的Secret Key;
app.loading(true);
$.ajax({
url: "https://aip.baidubce.com/oauth/2.0/token?" + grant_type + "&" + client_id + "&" + client_secret,
type: "POST",
dataType: "json",
async: false,
contentType: "application/json;charset=utf-8",
success: function (value) {
data = value;
app.loading(false);
},
error: function (err)
{
alert(err);
}
}).fail(function (error) {
data = error;
app.loading(false);
});
var grant_type = "client_credentials";
var client_id = "rlVkXeUg6L6hVbKwBygKEq6D";//必须参数,应用的API Key;
var client_secret = "cto5Hj1ZBLUISl6os8kqiasv7sP6YQBD";//必须参数,应用的Secret Key;
app.loading(true);
$.ajax({
url: "https://aip.baidubce.com/oauth/2.0/token?" + grant_type + "&" + client_id + "&" + client_secret,
type: "POST",
dataType: "json",
async: false,
contentType: "application/json;charset=utf-8",
success: function (value) {
data = value;
app.loading(false);
},
error: function (err)
{
alert(err);
}
}).fail(function (error) {
data = error;
app.loading(false);
});
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
js属于前台操作,不适合这类操作
js操作这个也是第一遇见了
获取token接口 支持POST GET方式。
就不写代码也能获取
https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=APIKEY&client_secret=SECRETKET 直接在浏览器输入 回车即可
错误肯定会返回提示的
建议你浏览器调试打开看看