upload form with doc type in ajax
$(".submitbtn").on("click", function(e) {
var form = $("#Form");
// you can't pass Jquery form it has to be javascript form object
var formData = new FormData(form[0]);
//if you only need to upload files then
//Grab the File upload control and append each file manually to FormData
//var files = form.find("#fileupload")[0].files;
//$.each(files, function() {
// var file = $(this);
// formData.append(file[0].name, file[0]);
//});
if ($(form).valid()) {
$.ajax({
type: "POST",
url: $(form).prop("action"),
//dataType: 'json', //not sure but works for me without this
data: formData,
contentType: false, //this is requireded please see answers above
processData: false, //this is requireded please see answers above
//cache: false, //not sure but works for me without this
error : ErrorHandler,
success : successHandler
});
}
});
Also in JavaScript:
- Lazy Loading Routes vue
- How can I display an image and text from an array on a webpage? Ask Question
- jquery get mouse page left and top
- javascript object destructuring rename
- javascript resize event
- watchman watch-del-all, and react-native start --reset-cache
- using this to get name of the clicked element
- DECIMAL TO BINARY CONVERSION javascript
- nodejs cluster example
- add object to array react hook
- button inside popover not viible
- next js styled components classname did not match
- javascript loops
- javascript select all table rows
- javascript cut string
- remove non prime numbers js
- owl carousel json not working
- javascript string literal
- nodejs mocha mock
- how to trim dates in react
- cadena promesas javascript
- javascript get origin url
- formatDoubl js
- mongoose connection nodejs