I first thought the problem was caused either from the form or from the php but it turned out that the js preventing the page was the cause.
Here is the code that worked for me:
jQuery(document).on('submit', '#wnform_settings', function(e) {
e.preventDefault();
$.ajax({
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function(element) {
if (element.lengthComputable) {
var percentComplete = ((element.loaded / element.total) * 100);
percentComplete = percentComplete.toFixed(0);
$("#progressBarback").val(percentComplete);
}
}, false);
return xhr;
},
type: 'POST',
url: $(this).prop('action'),
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
dataType: 'text',
beforeSend: function() {
setTimeout(() => {
$("#progressBarback").val(0);
}, 1000);
},
success: function(json) {
console.log(json);
},
error: function(xhr, ajaxOptions, thrownError) {
console.log(ajaxOptions + "\r\n" + thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});