본문 바로가기
js

ajax json 불러오기

by 멋진 개구리 2021. 1. 18.
반응형

<scriptsrc="https://code.jquery.com/jquery-3.3.1.min.js"></script>

<script>

varobj = '{"name":"John", "age":30, "city":"New York"}';// json

$.ajax({

url:'https://api.ip.pe.kr/json/',

dataType:'json',

type:'get',

success:function(json){

//var test = JSON.parse(json);

console.log(json);

console.log(json.country_code);

        }

    });

</script>

 

결과

반응형

댓글