Re: [问题]利用PSOT 大量资料上传该如何实现?

楼主: y2468101216 (芸)   2015-08-13 17:43:43
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了。
可能有错,请楼下指正
作者: aaa7513231 (浑沌与秩序)   2015-08-13 19:44:00
谢谢你 对于错误管理确实是个好方法 :)

Links booklink

Contact Us: admin [ a t ] ucptt.com