<div class="jb51code">
<pre class="brush:xhtml;">
login.onclick = function(){
var xhr = new XMLHttpRequest();
xhr.open("get","http://localhost/ajax2/test2.php?username="+username.value+"&pwd="+pwd2.value,true);
xhr.send();
xhr.onreadystatechange = function(){
if (xhr.readyState == 4) {
if (xhr.status>=200 && xhr.status<300) {
alert(xhr.responseText);
};
};
}
}
rush:xhtml;">
btn.onclick = function(){
ajax(
"GET","http://localhost/ajax2/my02.
PHP",{xingming:xingming.value,pwd:pwd.value},function(data){
console.log(data);
},function(errCode){
console.log(errCode);
}
)
02 速度. get的速度快
rush:xhtml;">
var sc = document.createElement("script");
sc.type = "text/javascript";
document.body.appendChild(sc);
sc.src = "http://localhost/ajax2/jsonp.
PHP?cb=myCallBack";
function myCallBack(data){
console.log(data);
}