-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
22 lines (17 loc) · 864 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
document.getElementById("getdata").addEventListener("click", function() {
var request = new XMLHttpRequest();
var url = "https://developer.trimet.org/ws/v2/vehicles?appID=D065A3A5DAE4622752786CEB9&routes=";
request.addEventListener("load", function() {
var response;
var htmlString = "";
response = JSON.parse(request.responseText);
htmlString += "<ul>";
for (var i = 0; i < response.resultSet.vehicle.length; i++) {
htmlString += "<li>" + response.resultSet.vehicle[i].signMessage + ": "+ -response.resultSet.vehicle[i].delay +" seconds late.</li>";
};
htmlString += "</ul>";
document.getElementById("results").innerHTML = htmlString;
});
request.open("GET", url + document.getElementById("query").value);
request.send();
});