引用jquery,有很方便的GET調用方法:
<!DOCTYPE?html><html>
<head>
<meta?http-equiv="content-type"?content="text/html;?charset=UTF-8">
<meta?name="viewport"?content="width=device-width,?initial-scale=1">
<!--?src值為文件位置路徑?-->
<script?type="text/javascript"?charset="UTF-8"?src="javascript/jquery-1.12.1.js"></script>
<title>測試案例</title>
<!--?語法:jQuery.getJSON(url,data,success(data,status,xhr))?-->
<script?type="text/javascript"?charset="UTF-8">
function?getToken(){
$.getJSON("http://localhost/kdapi/api/access_token",?{"id":111,"secret":2352532},?function(result){
alert(result.access_token);
});
}
</script>
</head>
<body>
<button?onclick="getToken()"?style="width:?120px;?height:?60px;">獲取Token</button>
</body>
</html>