for (var i = 3; i < Data.length; i++){
DataCreat(ProjectName, VersionName, Data[i], Stander01Year,
Stander02Year, function(msg){
if(msg !='done'){
alert(i+':end loop');
break;
}else{
alert(i+':ok');
}
});
}
DataCreat = function(ProjectName, VersionName, DataForCreat, Stander01Year,
Stander02Year, callback) {
var data_array = { FunctionCode: 5,
Pro_Name: ProjectName,
Ver_Name: VersionName,
Data: DataSend,
Stander01: Stander01Year,
Stander02: Stander02Year};
$.ajax({url : 'php/TotalFunctionCall.php',
data : data_array,
type : "post",
dataType : 'text',
timeout : 10000,
success:function(msg){
if(msg != 'ok'){
alert(msg);
callback('fail');
}
},error : function(xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
callback('ajax fail');
}}).done(callback('ok'));
};
你可以试试,基本上就是把ajax可能产生错误讯息的地方都接起来,
你这种需求应该会需要用到callback把错误接起来,用return会直接就return了。
可能有错,请楼下指正