如何创建外部javascript文件以跟踪用户并提醒数据
我在html页面中使用这段代码,但我需要一个单独的javascript文件来提醒数据 实际上,应该在html文件中创建一个变量,并将其发送到.js文件,该文件会提醒数据 但我无法将城市名称存储在变量中如何创建外部javascript文件以跟踪用户并提醒数据,javascript,geoip,Javascript,Geoip,我在html页面中使用这段代码,但我需要一个单独的javascript文件来提醒数据 实际上,应该在html文件中创建一个变量,并将其发送到.js文件,该文件会提醒数据 但我无法将城市名称存储在变量中 <html> <head> <title>home</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min
<html>
<head>
<title>home</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="//j.maxmind.com/js/apis/geoip2/v2.0/geoip2.js"></script>
<script>
geoip2.cityISPOrg(function (response) {
$("#country").html(response.country.names.en);
}, null, { w3cGeolocationDisabled: true });
</script>
</head>
<body>
<p>
<span id="country"></span>,
</p>
</body>
</html>
它的报警未定义,它未报警国家值,我认为国家值未存储在变量中。
谁能告诉我如何将值存储在变量中。你是说这样的吗
<html>
<head>
<title>home</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="//j.maxmind.com/js/apis/geoip2/v2.0/geoip2.js"></script>
<script>
geoip2.cityISPOrg(function (response) {
$("#country").html(response.country.names.en);
}, null, { w3cGeolocationDisabled: true });
</script>
</head>
<body>
<p>
<span id="country"></span>,
</p>
</body>
</html>
alert($("#country").html());