[英]Node js debugging not working in Visual Studio code (year 2020)
[英]Ajax call is not working in visual studio code(June 2020)
我正在嘗試從 openWeather API 獲取數據。它在崇高的文本中工作,但不在 Visual Studio 代碼(2020)中。下面是我的代碼:
$(document).ready(function() {
$("#submitweather").click(function() {
if ($("#city").val() != null) {
$.ajax({
url: "https://api.openweathermap.org/data/2.5/weather?q=" + $("#city").val() + "&units=metric&appid=" + "16730653e7fb54b543203fcee48a7abb",
type: "GET",
dataType: "json",
async: true,
success: function(result) {
console.log(result);
},
error: function(err) {
console.log(err);
}
});
} else
alert("city name should be entered");
});
});
HTML 代碼:
<div class="col-md-12">
<form>
<div class="row pb-5">
<div class="col-md-6">
<input type=" text" id="city" placeholder="Enter city" class="form-control">
</div>
<div class="col-md-6">
<button id="submitweather" class="btn btn-warning px-5">Search</button>
</div>
</div>
</form>
</div>
不知道具體錯誤,我在編輯器之間遇到過類似的 JS 問題,因為在一些復制和粘貼后隱藏了控制字符。 確保您的代碼中沒有任何隱藏的轉義/控制字符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.