What happens when you try to do the http call from an https initiated site:
jquery-1.9.1.min.js:5 Mixed Content: The page at 'https://******' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://ip-api.com/json'. This request has been blocked; the content must be served over HTTPS.
If you try to use https for this call you get:
jquery-1.9.1.min.js:5 GET https://ip-api.com/json 403 (Forbidden)
and if you try https://ip-api.com/json direct in your browser you get
{"status":"fail","message":"SSL unavailable for this endpoint, order a key at https://members.ip-api.com/"}
Incidentally, you also have two JS syntax errors in your code. Here is a corrected version (not that it helps in getting the ip stuff returned over https I'm afraid).
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
function preloadFunc()
{
$.ajax('https://ip-api.com/json')
.then(
function success(response) {console.log(response);
if(response.country!="India") {
window.location.replace("https://www.google.com/");
}
})
}
window.onpaint = preloadFunc();
</script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…