Skip to content
Permalink
b58d16b47b
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
1 contributor

Users who have contributed to this file

45 lines (33 sloc) 1.21 KB
function displayResult(firstname, lastname, number, email){
//Display Name
var Name = document.createElement("h1");
var fname = document.createTextNode(firstname + " " + lastname);
Name.appendChild(fname);
document.querySelector("#results").appendChild(Name);
//Display Number
var Num = document.createElement("h3");
var fNum = document.createTextNode(number);
Num.appendChild(fNum);
document.querySelector("#results").appendChild(Num);
//Display Email
var Email = document.createElement("h3");
var fEmail = document.createTextNode(email);
Num.appendChild(fEmail);
document.querySelector("#results").appendChild(Email);
}
function getJSON(jsonFile){
var ajaxCall = new XMLHttpRequest();
var url = jsonFile;
ajaxCall.onreadystatechange = function(){
if (ajaxCall.readyState == 4 && ajaxCall.status == 200){
var JsonObject = JSON.parse(ajaxCall.responseText);
for(i = 0;i < JsonObject.length; i++){
console.log(JsonObject[i].firstname);
displayResult(JsonObject[i].firstname, JsonObject[i].lastname, JsonObject[i].phone, JsonObject[i].email);
}
}
}
ajaxCall.open("GET", url, true);
ajaxCall.send();
}
getJSON("http://phonebk.develop.digitalmediauconn.org/phonebook.php?do=getAllPeople")