1
这个简单的代码在Chrome浏览器(显示你的IP),但不能在Firefox返回以下错误:jQuery的阿贾克斯不会在Firefox(使用以前版本的工作)工作,但在Chrome浏览器的
“发生错误:404错误“。
<script>$(document).ready(function()
{
$.ajaxSetup({cache: false});
$.ajax({
url: "https://freegeoip.net/json/",
dataType: "JSONP",
error: function(xhr)
{
console.log("An error occured: " + xhr.status + " " + xhr.statusText);
},
success: function(data)
{
console.log(data.ip);
}
});
});
</script>
这里的小提琴:https://jsfiddle.net/7ayo52Lx/5/
任何帮助表示赞赏。