$.getScript("http://./ipquery", function () {
(localAddress);//返回对象Object{city:"南昌市",province:"江西省"}
province = localAddress["province"];
province = (/省/, '');
city = localAddress["city"];
city = (/市/, '');
(province);//江西
(city);//南昌
});
只需更改你的url变量中 http// 为
//
,当页面加载http时,ajax请求将使用http协议,如果加载https,浏览器将ajax请求协议设置为https。即,您的代码应如下所示:
$.getScript("//./ipquery", function () {
(localAddress);//返回对象Object{city:"南昌市",province:"江西省"}
province = localAddress["province"];
province = (/省/, '');
city = localAddress["city"];
city = (/市/, '');
(province);//江西
(city);//南昌
});