Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(def getZipLookupUri zip callbackFuncName (+ '' zip '&country=US&callback=' callbackFuncName '&username=jimmyhoffa'))
(def makeSimpleJsonpGetRequest uri
(do (= xhr (new XMLHttpRequest()))
( 'GET' uri true)
(= xhr.onload (fn result (eval
(def createGeoNameResponseHandler callbackFunc
(= window.getLatLonFromResponse
(fn geoResponse
(callbackFunc ((fn (lat: lon: #0.lng)) (geoResponse.postalcodes.pop)))))
(def displayLatLon latLonObj ((jQuery '#latlon').text (+ ',' latLonObj.lon)))
(makeSimpleJsonpGetRequest (getZipLookupUri '80031' (createGeoNameResponseHandler displayLatLon)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment