I can't see why my code is not working. My html is:
<form name="admin_image" action="/index.php" method="post"enctype="multipart/form-data">
<input class="editor" type="text" name="image_title_100502002" value="" placeholder="Bildtitel">
<label for="fileToUpload_100502002" class="fileUpload">
<input type="file" name="fileToUpload" id="fileToUpload_100502002">
</label>
<input type="submit" name="delete_image_100502002" value="Bild löschen">
<span data-name="remove_image_100502002">Abbrechen</span>
<input class="ajax_submit_image" type="submit" name="submit_image_100502002" value="Speichern">
</form>
when submitting the form without ajax, everything works and the server side can process the $_FILES array, when submitting the form via ajax, it doesnt work, even though chrome dev tool shows the xhr beeing successfull. This is my Jquery ajax:
// send cms image via ajax
$("input.ajax_submit_image").click(function(event){
//dont submit form on click
event.preventDefault();
//save form parent in variable
var thisform = $(this).parent();
//set ajax data
var formdata = new FormData(thisform[0]);
// send ajax
$.ajax({
data: formdata,
processData: false,
contentType: false,
error: function() {
alert('an ajax error occured');
},
success: function() {
//return updated content
// $('form.show').next('div.currentcontent').empty().append('TEST');
//close the form after ajax submission
thisform.toggleClass('show');
// hide overlay when form is hidden
$('#cms_overlay').removeClass('show');
//reset id when current content is submitted when ajax finished
CMS.currenteditid= undefined;
},
type: 'POST'
});
})
Does anyone see why it does not work with ajax ? Thanks in advance!