google json view
get, post
type
- GET → request data Read ex) movie list search
- POST → request data Create, Update, Delete ex) join, withdrew, reset pw
- GET
http://naver.com?param=value¶m2=value2
- POST : data : {}
data: { param: ‘value’, param2: ‘value2’ }
get
? : data from here
& : more data
“?” front : Server Address, back : Movie code
- Server Address : https://movie.naver.com/movie/bi/mi/basic.nhn
- Movie number : code=161967
https://google.com/search?q=iphone&sourceid=chrome&ie=UTF-8
q=iphone (search)
sourceid=chrome (browser)
ie=UTF-8 (encoding)
ajax
$.ajax({
type: "GET",
url: "http://openapi.seoul.go.kr:8088/6d4d776b466c656533356a4b4b5872/json/RealtimeCityAir/1/99"
data: {},
success: function(response){
console.log(response['RealtimeCutyAir']['row'][0])
}
})
- type: “GET” : request GET
- url: request url
- data: accompany data(GET X)
- success: Execute the function with the response value of the server’s result value.
success: function(response){
// response : variable
console.log(response)
}
exchange Rate Calculator
<p class="rate">dollar-won exchange Rate : <span id="now-rate"></span></p><script>
$(document).ready(function () {
get_rate();
});
function get_rate(){
$.ajax({
type: "GET",
url: "http://spartacodingclub.shop/sparta_api/rate",
data: {},
success: function (response) {
let now_rate = response['rate'];
$('#now-rate').text(now_rate);
}
})
}
</script>