此请求已被阻止;内容必须通过HTTPS提供 This request has been blocked; the content must be served over HTTPS.

 $.getScript("http://ip.ws.126.net/ipquery", function () {             console.log(localAddress);//返回对象Object{city:"南昌市",province:"江西省"}             province = localAddress["province"];             province = province.replace(/省/, '');             city = localAddress["city"];             city = city.replace(/市/, '');             console.log(province);//江西             console.log(city);//南昌         });

只需更改你的url变量中 http// // ,当页面加载http时,ajax请求将使用http协议,如果加载https,浏览器将ajax请求协议设置为https。即,您的代码应如下所示:

 $.getScript("//ip.ws.126.net/ipquery", function () {             console.log(localAddress);//返回对象Object{city:"南昌市",province:"江西省"}             province = localAddress["province"];             province = province.replace(/省/, '');             city = localAddress["city"];             city = city.replace(/市/, '');             console.log(province);//江西             console.log(city);//南昌         });
    原文作者:小白
    原文地址: https://blog.csdn.net/qq_44217121/article/details/122766857
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞