Submit Formdata Data using jquery

Source: Internet
Author: User

54931716

http://yunzhu.iteye.com/blog/2177923

***********************************************

<!DOCTYPE HTML><HTML><Head>    <title>Test</title>    <MetaCharSet= "UTF8">    <Scriptsrc=".. /js/jquery-1.11.3.min.js "></Script></Head><Body>    <formID= "form">        <inputname= "File"type= "File" />        <inputname= "a"value= "1" />        <inputvalue= "2" />    </form>    <Button>Submit</Button></Body></HTML><Script>    $(function() {        //Monitor Upload Progress        varxhronprogress= function(fun) {xhronprogress.onprogress=Fun ;//Binding Monitoring            return function() {                //get XMLHttpRequest objects by $.AJAXSETTINGS.XHR ();                varXHR=$.ajaxsettings.xhr (); //determine if the listener function is a function                if (typeofxhronprogress.onprogress!== 'function')                    returnXHR; //If there is a listener function and the XHR object supports binding, the listener function is bound                if(xhronprogress.onprogress&&xhr.upload) {xhr.upload.onprogress=xhronprogress.onprogress; }                returnXHR; }        }        $('Button'). On ('Click', function() {            varFormData= NewFormData ($ ('#form')[0]);//automatic search of form information (input without the name attribute in the form is not searched), ie<=9 does not support FormdataFormdata.append ('b', 3);//You can also add additional form data$.ajax ({type:'Post', URL:'.. /.. /.. /material/jqueryfileupload?type=1', Data:formdata, ContentType:false,//This is required when there is a file to upload, otherwise the background does not recognize the starting location of the file stream (see: #1)ProcessData:false,//whether to serialize the Data property, default True (Note: False when type must be post, see: #2)xhr:xhronprogress (function(e) {//(see: #3)                    varpercent=e.loaded/e.total;//Calculate Percentage                    $('Body'). Append (' -'+percent); }), Success:function(data) {$ ('Body'). Append ('Complete'); }            })        })    })</Script>

Submit Formdata Data using jquery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.