我正在尝试使用PLUpload library.at fileUploaded函数上传大文件,我有ajax调用将图像上传到Amazon S3,但是ajax调用失败,提示错误网络连接被终止。请帮助如何重新启动或恢复我的请求
首先我使用 offline js检测到网络已关闭或运行正常,>
var run = function(){ Offline.check(); } setInterval(run, 3000);
每隔3秒检查一次网络连接是否可用。
重新连接后网络启动时,在启动功能上执行操作
Offline.on('up', function(){ if(ajax_response === null || ajax_response == 'error') { rename_file (oldname,newname) } });
将函数参数存储为全局变量以用于函数调用。
var ajax_response = null;
window.rename_file = function(oldname,newname)
{
var resp =null;
$.ajax({
url:'ajaxcall.php',
data:{action:'rename_file',new_name:newname,old_name:oldname},
async:false,
success:function(data,status)
{
resp = 'success';
},
error: function(jqXHR, textStatus, errorThrown) {
resp = 'error';
}
});
ajax_response.= resp;
return resp;
}