![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbA5MGC%2Fbtq5WNJwS9F%2FcNNNKGMWPzD1KfmycoLqf1%2Fimg.png)
[바미] JavaScript JSON 데이터 GET 하기.
·
프로그래밍(Web)/Javascript(TS,Node)
IP로 현재 지역을 조회 해야 하는 일이 생겨 찾아보게 되었습니다. var getJSON = function(url, callback) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'json'; xhr.onload = function() { var status = xhr.status; if (status === 200) { callback(null, xhr.response); } else { callback(status, xhr.response); } }; xhr.send(); }; 이렇게 함수로 정의하고, 저 getJSON을 사용하는 방법은 getJSON('http://query.yahooapis.com..