繁体   English   中英

报价未出现在网页上

[英]The quote isnt appearing on the webpage

我想做的是单击按钮时,引号出现在网页上,但无法正常工作。 我正在使用API

 $(".btn").on("click",function(){ $.ajaxSetup({cache:false}) $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&callback=",function(data){ $(".quote").html(data[0].content + "-" + data[0].title); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <div class = "container-fluid"> <div class = "row"></div> <div class = "text-center quote-box"> <h1 >Random Quote Generator</h1> <p class = "quote"> Click the button to get a random quote</p> </div> <div class = col-md-4 id = quote-button> <button class="btn btn-primary" type="submit" id = quote-button>New Quote</button> <button class="btn btn-primary" type="submit" id = quote-button><i class = "fa fa-twitter">Twitter</i></button> </div> </div> </div> 

http更改为https 问题可能是由于“混合内容”httphttps会被您的浏览器阻止。

  $(".btn").on("click",function(){
   $.ajaxSetup({cache:false})
   $.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&callback=",function(data){
    $(".quote").html(data[0].content + "-" + data[0].title);
  });
});

勾选此普拉克

当通过安全的HTTPS连接加载初始HTML ,但通过不安全的HTTP连接加载其他资源(例如图像,视频,样式表,脚本)时,就会发生混合内容 之所以称为混合内容,是因为同时加载了HTTPHTTPS内容以显示同一页面,并且初始请求通过HTTPS是安全的。 现代浏览器会显示有关此类内容的警告,以向用户指示此页面包含不安全的资源。

该请求有效,但浏览器阻止了它,因为它是跨源请求。 让服务器管理员必须启用cors或检查是否支持JSONP请求。

暂无
暂无

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

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