function createNewCharacter() { var formName = 'create-char-form'; var url = 'editCharacter.php'; var modalName = 'newCharModal'; create(formName, url, modalName); } function createNewStory() { var formName = 'create-story-form'; var url = 'editStory.php'; var modalName = 'newStoryModal'; create(formName, url, modalName); } function create(formName, url, modalName) { var form = $('#' + formName)[0]; var data = new FormData(form); //var file = $('#story-logo').prop('files')[0]; //data.append('file', file); jQuery.ajax({ url: url, data: data, cache: false, contentType: false, processData: false, method: 'POST' }).done(function(data, textStatus) { console.log("Success!"); console.log(data); console.log(textStatus); $('#' + modalName).modal('hide'); form.reset(); // Just a work around location.reload(); }).fail(function(jqXHR, textStatus) { if (409 == jqXHR.status) { var errorElement = $('