js formdata傳數組


var data=new FormData()for(var i=0,len=json.length;i<len;i++){
        data.append('json['+i+'][name]',json[i].name)
        data.append('json['+i+'][age]',json[i].age)
        data.append('json['+i+'][family][father]',json[i].family.father)
        data.append('json['+i+'][family][mother]',json[i].family.mohter)        for(var j=0,len2=json[i].skills.length;j<len2;j++){
            data.append('skills['+i+']['+j+']',json[i].skills[j])
        }
    }
     $.ajax({         url:'demo.php',         type: "Post",         dataType: "json",         cache: false,//上傳文件無需緩存
         processData: false,//用於對data參數進行序列化處理 這里必須false
         contentType: false, //必須
         data:data,         success:function (res) {             console.log(res);
         },         error:function (error) {             console.log(error);
         }
     })


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM