87,910
社区成员
发帖
与我相关
我的任务
分享
function $ajax(obj){ //超简易ajax
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = handleStateChange;
xhr.open("get",obj.url,true);
xhr.send();
function handleStateChange(e){
var result;
if(xhr.readyState == 4){
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
result = JSON.parse(xhr.responseText);
obj.success && obj.success(result);
}
}
}
}
$ajax({
url:"xxx",
success:function(data){
$("#line").select({
title: "选择线路",
items:data,
onChange: function (d) {
console.log(this, d);
},
onClose: function () {
console.log("close");
},
onOpen: function () {
console.log("open");
},
});
}
});