프로그래밍/JavaScript
XMLHttpRequest 와 HttpRequest의 차이점
buykiwi
2015. 6. 2. 13:28
XMLHttpRequest:
- javascript 개제임.
- 브라우저내에서 자바스크립트를 사용하여 HTTP 요청을 가능케 하는 개체임
- 주로 비동기적 통신 (웹페이지를 re-load할 필요가 없음)
- 응답(response)은 주로 xml이나 json 형식임 --> 응답을 parse하여 웹페이지를 "즉시" 갱신한다.
- 즉, "Ajax" 방식으로 통신함. --> jQuery의 Ajax method를 이용하면 더욱 간단해짐.
HttpRequest:
- server-side 개체임.
- 웹서버로 요청된 내용을 담고 있는 개체임.
- 동기적 통신
XMLHttpRequest in a standard javascript object that allows you to make HTTP Requests from the browser in javascript.
HttpRequest is a server side object that represents a request to the server.
In summary - XMLHttpRequest works in the browser, HttpRequest in the web server. They also have completely different roles. XMLHttpRequest is for fetching web resources within the browser. HttpRequest represents an incoming request.