tailieunhanh - Beginning Ajax with PHP (AJAX BASICS Table 2-3. XMLHttpRequest (P.2))

Quấn sách này rất cần cho những ai đam mê web, muốn tự tay là cho mình một trang web tương đối hoàn chỉnh về web thương mại với sự kết hợp của PHP và Ajax, quấn sách cung cấp cho bạn đầy đủ các thủ thuật cần thiết để tạo nên một trang web với tốc độ load dữ liệu nhanh . | 9 27 06 11 51 AM Page 14 14 CHAPTER 2 AJAX BASICS Table 2-3. XMLHttpRequest Object Methods Method Description abort Cancels the current request getAllResponseHeaders Returns all HTTP headers as a String type variable getResponseHeader Returns the value of the HTTP header specified in the method open Specifies the different attributes necessary to make a connection to the server allows you to make selections such as GET or POST more on that later whether to connect asynchronously and which URL to connect to setRequestHeader Adds a label value pair to the header when sent send Sends the current request While the methods shown in Table 2-3 may seem somewhat daunting they are not all that complicated. That being said let s take a closer look at them. abort The abort method is really quite simple it stops the request in its tracks. This function can be handy if you are concerned about the length of the connection. If you only want a request to fire for a certain length of time you can call the abort method to stop the request prematurely. getAllResponseHeadersO You can use this method to obtain the full information on all HTTP headers that are being passed. An example set of headers might look like this Date Sun 13 Nov 2005 22 53 06 GMT Server Apache Win32 PHP X-Powered-By PHP Content-Length 527 Keep-Alive timeout 15 max 98 Connection Keep-Alive Content-Type text html 9 27 06 11 51 AM Page 15 CHAPTER 2 AJAX BASICS 15 getResponseHeader headername You can use this method to obtain the content of a particular piece of the header. This method can be useful to retrieve one part of the generally large string obtained from a set of headers. For example to retrieve the size of the document requested you could simply call getResponseHeader Content-Length . open method URL async usemame pswd Now here is where we start to get into the meat and potatoes of the XMLHttpRequest object. This is the method you use to open a connection to a .