1
Kann mir jemand helfen, ein Formular mit AJAX einzureichen? Der Zweck des Formulars besteht darin, eine Datei hochzuladen. Das spezifische Problem, das ich habe, ist, wie man die action
und enctype
Parameter erfasst. Meine Form:Formular-Upload mit Ajax und Jquery senden
<form role="form" method="post" action="http://localhost:3000/api/some_url" enctype="multipart/form-data">
<input type="file" name="file" id="file">
<input id="submit" type="submit" class="btn btn-primary" value="Submit">
</form>
Ich brauche so etwas wie:
$.ajax({
type: "POST",
url: 'http://localhost:3000/api/some_url',
action: 'http://localhost:3000/api/some_url',
enctype: 'multipart/form-data',
headers: {
'x-access-token': this.token,
},
success: function() {
console.log('success!')
},
error: function (a, b, c) {
console.log(a)
console.log(b)
console.log(c)
}
})
Kann jemand helfen?
Vielen Dank im Voraus!
Für Datei-Upload dropzone.js versuchen, die einfach und fantastisch –