1; (function ($) {2$.fn. Uploadfilessy =function(useroption) {3 varoption = {4PostURL: "",//Upload Path5Callblackfunction:function() { }//callback function6 };7 varOptions = $.extend ({}, option, Useroption | | {});8 9 varFile = $ ( This);TenFile.change (function () { One varIframe_form = "<iframe id= ' Uploadfilessyiframeforid ' name= ' uploadfilessyiframeforname ' style= ' display:none; ' ></iframe><form id= ' Uploadfilessyformforid ' method= ' post ' target= ' uploadfilessyiframeforname ' action= ' ' enctype= ' multipart/form-data ' ></form> '; A $ (document.body). Append (iframe_form); - - varFileparent =file.parent (); the - varForm = $ ("#UpLoadFileSSYFormForId"); - variframe = $ ("#UpLoadFileSSYIframeForId"); - +Form.attr ("Action", Options.posturl); - form.append (file); + form.submit (); A atIframe.load (function () { - file.appendto (fileparent); - varresult = Iframe.contents (). Find (' body '). HTML (). Replace (/\<[^\>]*\> ([^\<]*) \<[^\>]*\>/g,function($ A, $) {return$; });//Todo here can actually be filtered without the regular -Options.callblackfunction.call ( This, eval (result)); - Iframe.remove (); - Form.remove (); in }); - }); to } +}) (JQuery);
Uploading Files asynchronously