javascript - Ajax send image within data -
I am trying to send some data to Ajax and this data may contain an image.
I there is no form , so I can not present in a traditional way. This is my html: Whenever the user changes the file, I get that value. When I press the OK button I call an Ajax function. I am currently getting the error on Chrome console Unkit Type Error: Invalid Orientation Ajax In-line How far am I far away from Ajax by sending an image with other data? You need to send form data as data for Ajax request, so add additional parameters Should also be added to fomdata
& lt; Input type = "file" accept = "image / png, image / jpg, image / jpeg, image / bmp" id = "addProduct_image" & gt;
var files; $ (Document) .on ('change', '#addProduct_image', function (e) {readyUpload (e);}); Upload the function ready (events) {files = event.target.files; }
$ (document) .on ('click', '#addProduct_OK', function (e) {var img = new form data ($); $ .ee (files, functions (key, value) } {Img.append (key, value);}); $ .ajax ({url: 'responses / product val (), description: $ ("# addProduct_description"). Val (), image: img, status: php $ ("# AddProduct_status"). Val ()}, success: function (data) {console.log (data) );}});});
$ (document) .on ('click', '#addProduct_OK', function (e) {var img = new form data (); $ .EEC (Files, functions (key, values) {img.append (key, value);}); img.append ('title', $ ("# ('' condition '', $ (" # addProduct_status "). Val () ); $ .ajax ({url: 'responses / product.fip; type = product avatar', type: 'po (Data);}}};});
Comments
Post a Comment