Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

AJAX 요청 방법 본문

Study/WEB

AJAX 요청 방법

awakerrday 2020. 9. 1. 19:59

1. XMLHttpRequest(XHR) 사용

<script>
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() { // Call a function when the state changes.
    if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
        // Request finished. Do processing here.
    }
}
xhr.open('GET', 'https://www.naver.com/');
xhr.withCredentials = true; // 세션ID 포함
xhr.send();
</script>

<script>
ar xhr = new XMLHttpRequest();
xhr.open("POST", '/server', true);
xhr.withCredentials = true; // 세션ID 포함

//Send the proper header information along with the request
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

xhr.onreadystatechange = function() { // Call a function when the state changes.
    if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
        // Request finished. Do processing here.
    }
}

xhr.send("foo=bar&lorem=ipsum");
// xhr.send(new Int8Array()); 
// xhr.send(document);
</script>

2. jQuery를 이용한 ajax 사용 (https://api.jquery.com/jquery.ajax/)

 

3. Fetch (https://developer.mozilla.org/ko/docs/Web/API/Fetch_API/Fetch의_사용법)

: XSS 응용할 때 간편

 

'Study > WEB' 카테고리의 다른 글

Error-based SQLi(Oracle DB)  (0) 2020.09.01
JSP 업로드 우회  (0) 2020.09.01
불충분한 인증/인가  (0) 2020.03.18
SQLi 기록  (0) 2019.07.11
XSS(Cross-Site Scripting) 종류 및 특징  (0) 2019.03.14
Comments