
正文
用js获取access_token
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
尝试用js获取access_token 最终失败告终,哈哈
1需要 appId和AppSecret 这两个参数是要保密的,建议不要暴露在外面,以防被别有用心的人利用。
$.ajax({
url:'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=appid&secret=secret',
type:"get",
async: true,
success: function (result) {
},
error: function (result) {
console.log(result);
}
});
Ajax跨域请求报错:XMLHttpRequest cannot load ''. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' ' is therefore not allowed access
但是可以在network中查看到返回值,只是ajax不走success ,调到error中了。







