简体   繁体   English

有关使用$ .ajax()在codepen.io中发布请求的问题

[英]questions about using $.ajax() to post request in codepen.io

well, codepen.io is really an awesome front end designing web, but somehow I meet some problems. 好吧,codepen.io确实是一个很棒的前端设计Web,但是以某种方式我遇到了一些问题。 I try to use $.ajax() to request the JSON from weatherapi in myworks in codepen.io 我尝试使用$阿贾克斯()从请求JSON weatherapimyworks在codepen.io

here are my codes 这是我的密码

 function clickButton(){

 $.ajax({
 type: "GET",

 url:"api.openweathermap.org/data/2.5/weather?lat=35&lon=139&APPID=c7294a560e0aac2d8389242ba90f4a6a",
 dataType: "jsonp",

 success: function(response){
  console.log(response);
 },
 error: function(xhr,status,error){
  console.log(status);
 }
});

}

i have used a lot of ways to test whether this url can be used, and just find that it works well. 我已经使用了很多方法来测试该网址是否可以使用,并且发现它工作得很好。 However, i cant figure out why this ajax request always fail...... 但是,我不知道为什么这个ajax请求总是失败......

I have read about another question that similar to my situation, the solution is to add "http://" before the url, but it seems that add it before doesnt work for me...... 我已经阅读了另一个与我的情况类似的问题,解决方案是在url之前添加“ http://”,但似乎在我之前添加它对我不起作用……

I used the same api in my project. 我在项目中使用了相同的api You have to add https:// for it to work. 您必须添加https://才能起作用。 This is very important or it wont work. 这非常重要,否则将无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM