XMLHttpRequest
Object is used to transfer data between the browser and the server.
ajax simple case to access the text, in server environments:
// Create ajax objects, incompatible versions IE low var XHR = new new the XMLHttpRequest () ; // onreadstatechange specify a callback function, dynamically monitor the communication state (the readyState), . XHR the onreadystatechange = function () { // communication state 4 when indicating the browser has been fully accepted data server, which has failed to accept this IF (XHR. the readyState === . 4 ) { // http status indicates a status code 200 indicating a normal IF (XHR. status === 200 is ) { Document . Write (XHR. the responseText ) ; } the else { Document . Write (XHR. the statusText ) ; } } } ; . XHR the onerror = function (E) { Console . error (XHR. the statusText ) ; } ; // the GET mode, the path for the path under local environment, true for asynchronous request, to false synchronous XHR. Open ( 'the GET' , './1.txt' , to true ) ; . XHR Send ( null ) ;result
The next article ajax return data type