function createNewCharacter() { var formName = 'create-char-form'; var url = 'createCharacter.php'; var modalName = 'newCharModal'; create(formName, url, modalName); } function createNewStory() { var formName = 'create-story-form'; var url = 'createStory.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'); }).fail(function(jqXHR, textStatus) { if (409 == jqXHR.status) { var errorElement = $('