javascript - Form submit File and complex Json -
how submit complex json object along file upload?
i can simple json object successfully, fails complex json:
e.g. [file] + { simple: object } -- okay
e.g. [file] + {some: {complex: 'asdf'}, object:['str1','str2']} -- fails
//here simple json data var params = {simple: 'jsondata'}; //here header enable json stuff var headers = { 'content-type': 'application/json', 'accept': 'application/json, text/javascript, */*', 'datatype': 'json' }; //assume have files in html form var files = fi.button.fileinputel.dom.files; form.submit({ url: '/some/api', waitmsg: 'uploading file...', headers: headers, params: params, success: function(a, b) { //done... } }); the code above fails when params complex json object more 1 layer. using extjs, uses jquery guess html form question same across different js libs.
when doing file uploading, ext form post hidden iframe, need parse data such.
Comments
Post a Comment