looking for form file transfer done event! jquery ajax -


i'm doing file upload "pecl uploadprogress" status while using "beforeunload" warning if user try close window, activated on summitting.

$('#form').click(function() {     $('#upload').submit();     ajaxd();         setinterval("ajaxd()",1000);      (...)      $(window).bind("beforeunload", function() {     /*  return true || confirm("do want close?"); */         return confirm("do want close?");      });  }  function ajaxd() { $.ajax({     datatype: "json",     (...) // , workaround progress upload-bar     }); } 

now need unbind "beforeunload" somewhere ...

$(window).unbind(); 

... where? $.ajax({ }).done or .complete not work here, because function repeating. .ajaxstop. need event @ "file transfer done", unbind. use like

if $progress_percent > 90 { unbind() } 

(when file-transfer done, form follows target (action). page close. before script got 100%. user gets warning @ unload. that's try avoid using >90 instead of ==100.)

but don't way. got better solution?

if had used php sessions, javascript event would've been unbound in case when $_session["upload_progress_xxx"]["done"] true, or upload error detected.


Comments