第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我正在嘗試使用 jQuery 調(diào)用此 API,并且我已經(jīng)包含了正確的 cdn,但它顯示“$ 未定義”

我正在嘗試使用 jQuery 調(diào)用此 API,并且我已經(jīng)包含了正確的 cdn,但它顯示“$ 未定義”

拉風的咖菲貓 2023-12-19 20:48:59
我正在嘗試調(diào)用此 API,但它不起作用,并且給出 $ is not Defined 的錯誤。我已經(jīng)使用了正確的 API 令牌廣告,其中包含 HTML 中的 jquery CDN。這是 HTML 和 JS 的代碼。var express = require('express');var app = express();var hbs = require('hbs');app.set('view-engine', 'hbs');app.use(express.static(__dirname + '/public'));app.get('/', function(req, res){    $.ajax({    headers: { 'X-Auth-Token': 'my api token' },    url: 'https://api.football-data.org/v2/competitions',    dataType: 'json',    type: 'GET',       }).done(function(response) {        // do something with the response, e.g. isolate the id of a linked resource           res.send(response);       });})app.listen(3000);HTML 代碼如下:<!DOCTYPE HTML><html><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <title>Document</title></head><body></body><script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256- WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script><script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script></html>我收到的錯誤是“$ 未定義”。
查看完整描述

1 回答

?
慕俠2389804

TA貢獻1719條經(jīng)驗 獲得超6個贊

您在這里混合了后端和前端代碼。另外,在前端,您還包含兩個不同的 jQuery 版本。


我建議將前端代碼更改為如下所示:


<!DOCTYPE HTML>

<html>

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Document</title>

</head>

<body>


<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>   

<script>

  $.ajax({

    headers: { 'X-Auth-Token': 'my api token' },

    url: 'https://api.football-data.org/v2/competitions',

    dataType: 'json',

    type: 'GET',

  }).done(function(response) {

    // do something with the response

    console.log(response);

  });

</script>


</body>

</html>


查看完整回答
反對 回復 2023-12-19
  • 1 回答
  • 0 關(guān)注
  • 141 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號