當前位置:編程學習大全網 - 網站源碼 - 請問html的js調用webapi接口?

請問html的js調用webapi接口?

引用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>

  • 上一篇:django同壹個project下的不同APP的model之間,可以建立壹對多,壹對壹,或者多對壹的關系嗎?
  • 下一篇:可以上傳或下載文件的網站程序源碼
  • copyright 2024編程學習大全網