Ajax Tutorial

AJAX

 

The HTTP method to use for the request (e.g. "POST""GET""PUT"). 

$.ajax() can be used to send http GET, POST, PUT, DELETE etc. request. It can retrieve any type of response from the server.

Asynchronous JavaScript and XML

Ajax is a technique for creating fast and dynamic web page.

XMLHTTPRequest

readyState

0 : Request not initialised

1 : Server connection established

2 : request received

3 : processing request

4 : Request finished and response is ready.

 

Response Text of response XML

200 :  “OK”

403 : “forbidden”

404 : “Not Found”

var xhttp = new XMLHttpRequest();

xhttp.onreadystatechange =. function (){

}

<button id="button" onclick="loadData()">Submit</button>
<div id="demo">hi how are you</div>
<script>
function loadData(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
document.write(this.responseText);
}
};
xhttp.open('GET',"fls/transcript.txt",true);
xhttp.send();
}
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *