【发布时间】:2017-03-18 12:53:11
【问题描述】:
这个简单的代码在 Chrome 中有效(显示您的 IP)但在 Firefox 中无效,返回以下错误:
“发生错误: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/
感谢任何帮助。
【问题讨论】:
标签: javascript jquery ajax google-chrome firefox