jQuery(document).ready(function($) { // Code submission jQuery('#code_form').submit(function(e) { e.preventDefault(); // this disables the submit button so the user stays on the page // Validation let code = $('input[name=code]').val(); if ( code.length < 8 ) { jQuery('#resp').html('Code ist zu kurz!'); } else { data = {'code' : $('input[name=code]').val(), 'action' : 'submit_code', 'format' : $('select[name=format]').val() }; // ajax call $.ajax({ type: "POST", dataType: "json", url: frontendajax.ajaxurl, data: data}) .done(function(msg){ jQuery('#resp').html(msg.resp); }) .fail( function(eins) { console.log("Fehler", eins);}); } }); });