prooduction version 1
This commit is contained in:
29
includes/js/ajax.js
Normal file
29
includes/js/ajax.js
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
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);});
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user