AJAX-get或post数据
1:POST
try {
var xmlhttp = new XMLHttpRequest();
}
catch (e) {
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.open("POST", "AjaxUpdate.aspx", false);
xmlhttp.setRequestHeader("Content-Type", "text/html");
xmlhttp.send(result);
if (xmlhttp.readyState != 4 && xmlhttp.status != 200)
xmlhttp.statusText;
else
xmlhttp.responseText;
2:GET
try {var xmlhttp = new XMLHttpRequest();
}
catch (e) {
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
//escape对string做编码以免乱码
xmlhttp.open('get', 'XXXX.aspx?username=' +escape(document.getElementById('TextBox_UserNamer').value), true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('Checker').innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send();