Created
January 29, 2015 19:11
-
-
Save bdfinlayson/1916c1b3f5bcdfad95f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| var userZipCode, | |
| startingUrl, | |
| customUrl; | |
| document.querySelector('#submitButton').addEventListener('click', function() { | |
| userZipCode = document.querySelector('#userZipCode').value; | |
| startingUrl = 'https://api.wunderground.com/api/152eccaad753eb4b/forecast10day/q/37207.json'; | |
| customUrl = startingUrl.replace('37207', userZipCode); | |
| console.log("The user's zip code is: " + userZipCode); | |
| console.log("The starting url was: " + startingUrl); | |
| console.log("The weather json file link should be: " + customUrl); | |
| }); | |
| function getJSON(customUrl, cb){ | |
| var request = new XMLHttpRequest(); | |
| request.open('GET', customUrl); | |
| request.onload = function () { | |
| if (this.status >= 200 && this.status < 400) { | |
| cb(JSON.parse(this.response)); | |
| } | |
| } | |
| request.send(); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment