Showing
1 changed file
with
16 additions
and
0 deletions
api받을수있는코드.js
0 → 100644
1 | +var xhr = new XMLHttpRequest(); | ||
2 | +var url = 'http://apis.data.go.kr/1390802/AgriFood/FdCkry/getKoreanFoodFdCkryList'; /*URL*/ | ||
3 | +var queryParams = '?' + encodeURIComponent('serviceKey') + '='+'R7bFhjvvAMmxJxzcrL8NWkYHVa227zfpwvpwgXxcixNdMY0EbdbsbCboj3zXEsXniKNHyqu2dEllJCRk1LsdxA%3D%3D'; /*Service Key*/ | ||
4 | +queryParams += '&' + encodeURIComponent('service_Type') + '=' + encodeURIComponent('xml'); /**/ | ||
5 | +queryParams += '&' + encodeURIComponent('Page_No') + '=' + encodeURIComponent('1'); /**/ | ||
6 | +queryParams += '&' + encodeURIComponent('Page_Size') + '=' + encodeURIComponent('20'); /**/ | ||
7 | +queryParams += '&' + encodeURIComponent('food_Name') + '=' + encodeURIComponent('밥'); /**/ | ||
8 | +queryParams += '&' + encodeURIComponent('ckry_Name') + '=' + encodeURIComponent('조리'); /**/ | ||
9 | +xhr.open('GET', url + queryParams); | ||
10 | +xhr.onreadystatechange = function () { | ||
11 | + if (this.readyState == 4) { | ||
12 | + alert('Status: '+this.status+'nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'nBody: '+this.responseText); | ||
13 | + } | ||
14 | +}; | ||
15 | + | ||
16 | +xhr.send(''); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment