87,990
社区成员
发帖
与我相关
我的任务
分享
function test(){
$.get("/a",function(data){
alert("a");//可以触发
$.get("/b",function(data){
alert("b");//不能触发
});
});
}
function test() {
newajax("/a", function (data) {
alert("a"); //可以触发
setTimeout(function(){
newajax("/b", function (data) {
alert("b"); //可以触发
});
},0)
});
}
function test() {
newajax("/a", function (data) {
alert("a"); //可以触发
newajax("/b", function (data) {
alert("b"); //可以触发
});
});
}
function newajax(url, callback) {
var xmlhttp;
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
callback(xmlhttp.responseText);
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
}