如果您使用j Query和Ajax混合体来管理像这样的用户上载表格的头端:
$( form :button ).click(function(){
var formData = new FormData($("form")[0]);
$.ajax({
url: /upload ,
type: POST ,
xhr: function() {
myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){
myXhr.upload.addEventListener( progress , progressHandlingFunction, false);
}
return myXhr;
},
data: formData,
success: function (res) {
alert("Uploaded");
},
cache: false,
contentType: false,
processData: false
});
});
使用<代码>sync:false,阻止所有浏览器移动,直至上载完成或使用某种舱位功能,如上载<
,以便通知用户,离开网页将中断上载?
$(window).bind( beforeunload , function(){
return If you leave this page, your upload will not complete! Continue? ;
});
在Ajax,只有上载时才能运行功能吗?