ajax example
HTML
<textarea id="log"></textarea>
<input type="button" id="button" value="Click Me">
CSS
#log{
width: 500px;
height:200px;
}
JavaScript
var i = 0;
function log(s) {
$('#log').val($('#log').val() + '\n' + (++i) + ': ' + s);
}
log('before ajax call');
//setup the event handler for the button
//disable the button for now (this will be enabled when the data is received)
function loadDoc(){
$.ajax({
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = "aaaa";
}
};
xhttp.open("GET", "ajax_info.txt", true);
xhttp.send();
});
}
log('after ajax call');
$(document).ready(function() {
log('document ready');
setTimeout(function() {
log('timeout');
}, 1000);
});