IOS ajax动态获取select数据问题
问题: ios 使用ajax动态加载select的数据时,弹出的数据是旧的option数据,不是当次加载的最新数据(感觉ajax和select行为并行的),
解决办法: 先让select失去焦点不弹出option选项,等ajax加载完数据后再让它获取焦点弹出最新加载的数据.
<select name="jsUser" id="_jsUser_'+order.orderId+'" onblur="blurFunction()" onfocus="findJsUser('+order.orderId+')" class="select-category" style="width:75px;"><option value="">请选择</option></select>
var flag = false;
function blurFunction(){
if(flag){
flag = false;
}
}
function findJsUser(orderId){
if(!flag){
$("#_jsUser_"+orderId).blur();
}
if(!flag){
$.ajax({
url: "findJsUser",
type: "POST",
async: false,
dataType: "json",
data: {orderId: orderId},
success:function(data){
$("#_jsUser_"+orderId).empty();
$("#_jsUser_"+orderId).append("<option value=''>请选择</option>");
$.each(data, function(i,t){
$("#_jsUser_"+orderId).append("<option value='"+t.id+"' >"+t.nickName+"</option>");
});
if(!flag){
flag = true;
$("#_jsUser_"+orderId).focus();
}
},
error:function(e){
alert("失败,请稍后重试!");
}
});
}
}