-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajaxJQ.html
46 lines (41 loc) · 1.27 KB
/
ajaxJQ.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<html>
<head>
<style>
#old {
font-size: 8px;
background-color: #ccc;
}
</style>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<input id='query' type="text">
<button id='btnGet'>查询</button>
<div id='newDiv'>
<div id='city' style="color:red;">城市:</div>
<div id='province' style="font:12px '微软雅黑';">省份:</div>
<div id='country' style="color:red;">国家:</div>
<a id='url'></a>
</div>
<div id='old'></div>
</body>
<script>
var ipstring = '218.4.255.255';
var btn = document.getElementById('btnGet');
var old = document.getElementById('old');
var newDiv = document.getElementById('newDiv');
$("button").click(function(){
ipstring = $('#query').val();
$.ajax({url:'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=' + ipstring,success:function(evt) {
console.log(evt);
city.innerHTML = evt.city;
province.innerHTML = evt.province;
country.innerHTML = evt.country;
url.href = evt.url;
// url.innerHTML = '去查看-->' + jdata.title;
btn.innerHTML = '加载完成!';
}
});
});
</script>
</html>