WordPress + JavaScipt + AJAX + MySQL: insert query for form

I’ve cleaned everything a little bit. Now it looks like that: ajax.js function ajaxSubmit(e){ var nazwa_szkolenia = document.getElementById(“nazwa_szkolenia”).value; var Data_szkolenia = document.getElementById(“Data_szkolenia”).value; var Godzina = document.getElementById(“Godzina”).value; var Max_pacjent = document.getElementById(“Max_pacjent”).value; var dataString = []; dataString[‘nazwa_szkolenia1’] = nazwa_szkolenia; dataString[‘Data_szkolenia1’] = Data_szkolenia; dataString[‘Godzina1’] = Godzina; dataString[‘Max_pacjent1’] = Max_pacjent; if (nazwa_szkolenia == ” || Data_szkolenia == ” || … Read more

Scripts for shortcode: concatenate or load separately? [closed]

Why get into too much mess? Why not just look for your shortcode in content and widgets and then decide whether to enqueue a script/style or not. Use this code to see if your shortcode is being used or not. function check_shortcode($text) { $pattern = get_shortcode_regex(); if ( preg_match_all( “https://wordpress.stackexchange.com/”. $pattern .’/s’, $text, $matches ) … Read more

Creating own shortcode – echoeing php variable based on JS variable

You can’t add logic for changing in that way. You need react on user “front-end” event with js. Also this construction will work wrong: document.getElementById(\”form\”).innerHTML = \”[contact-form-7 id=\”formId\”]\”; Will be always print [contact-form-7 id=\”formId\”], because js can’t do_shortcode function itself. If you wanna make it simple(without ajax process) you need: 1) Print all forms with … Read more

Making an ajax request from a different domain

If you want to use Admin-Ajax to output the content, you should use echo instead. There is nothing to be viewed when you use return, so you’ll get a 0. This quotation from the codex explains further about the 0 response: If the Ajax request fails in wp-admin/admin-ajax.php, the response will be -1 or 0, … Read more