-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript2.js
57 lines (28 loc) · 1.51 KB
/
script2.js
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
47
48
49
50
51
52
53
54
55
56
$(document).ready(function(){
$("#submit").click(function(){
search();
});
});
function search() {
var searchuser = document.getElementById("country").value;
var link= "https://restcountries.eu/rest/v1/name/"+searchuser;
console.log(searchuser);
$.ajax({
url: link,
context: document.body
}).done(function(response) {
console.log(response);
$("body").append("<li>"+ "<h3>" +"-----> The Country that you search for is called: " + response[0].name + " <----- </h3>" +"</li>");
$("body").append("<li>" + "<h3>"+ "The Capital is: " + response[0].capital +"</h3>"+ "</li>");
$("body").append("<li>" + "<h3>"+ "The Region is: " + response[0].region +"</h3>"+ "</li>");
$("body").append("<li>" + "<h3>"+ "The Subregion is: " + response[0].subregion +"</h3>"+ "</li>");
$("body").append("<li>" + "<h3>"+ "The Timezone is: " + response[0].timezones +"</h3>"+ "</li>");
$("body").append("<li>" + "<h3>"+ "The Borders of this country are: " + response[0].borders +"</h3>"+ "</li>");
$("body").append( "<li>" + "<h3>" + " The population is: " + response[0].population + "</h3>" +"</li>");
$("body").append("<li>"+ "<h3>"+ "Alternative spellings:" +"</h3>"+ "</li");
for (var i=0; i<response[0].altSpellings.length-1 ;i++){
$("body").append( "<ul>" + "<h3>" + response[0].altSpellings[i] + "</h3>"+"</ul>");
}
$("body").append("<hr>"+"<hr>"+"<hr>"+"<hr>");
});
}