不知道为什么,最近async:false不生效
app中用的mui框架,项目已经上线很久了,最近出问题,一检查都是这个原因造成的,不方便吧所有的代码都放到aiax中,有没有大神知道原因。最近不知道怎么就突然这样了,下面是部分代码
self.setCostCenter = function(index){
console.log("当前乘客的下标:"+index+",id="+self.passenger[index].USER_ID);
var current_user_id = self.passenger[index].USER_ID;
var newArr = [];
var picker = new mui.PopPicker({
layer: 1
});
mui.ajax(BASE_URL + #########',{
type:"POST",
async:false,
data:{
realuserID:current_user_id
},
success:function(result){
console.log("1544--"+JSON.stringify(result));
var costCenterId = result.COST_CENTER_ID;
var selectCost = result.SELECT_COST_CENTER;
console.log("成本中心ID:"+costCenterId +",是否可选其他:"+selectCost);
//限制成本中心选择
if(selectCost == "0" && (costCenterId != null && costCenterId.length > 2)){
for(var i = 0;i < costCenterNameArr.length;i++){
console.log("1553--"+costCenterNameArr[i]);
if(costCenterId == costCenterIdArr[i]){
newArr.push({value:costCenterIdArr[i],text:costCenterNameArr[i]});
}
}
}else{
for(var i = 0;i < costCenterNameArr.length;i++){
console.log("1560--"+costCenterNameArr[i]);
newArr.push({value:costCenterIdArr[i],text:costCenterNameArr[i]});
}
}
}
});
console.log("1566---"+newArr);
picker.setData(newArr);
picker.show(function(SelectedItem) {
var itemCallback=picker.getSelectedItems();
console.log(self.passenger[index].costCenterId+"---------"+self.passenger[index].costCenterName)
self.passenger[index].costCenterId = itemCallback[0].value;
self.passenger[index].costCenterName = itemCallback[0].text;
})
};
点击事件以后,他先执行picker.setData(newArr);picker.show这儿了,造成点出来的东西是空白的,ajax里面我打印了有值的,吧这个方法放到ajax里面就好了,,,求大神指点,万分感谢,着急
你的ajax请求,是不是跨域了?