ajax的get请求与编码
window.onload = function(){
document.getElementById('username').onblur = function(){
var name = document.getElementById('username').value;
name = encodeURIComponent(name); // 编码
var request = new XmlHttpRequest();
request.open('get', 'demo.php?name='+name);
request.onreadystatechange = function(){
if (request.readystate == 4 && request.status == 200) {
var str = request.responseText();
alert(str);
}
}
request.send();
}
}