Plugin uses ajax to call php function
-
Hi I’m just wondering the best way to do this. External php is ‘Hacky’ (explained after code) in WordPress but works (see snippet below), I’m assuming by the nature of php i can’t call a function inside the UI file (below):
<input type="text" placeholder="function search" onkeyup="search(this.value)"> <script> xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById(\'search\').innerHTML = xmlhttp.responseText; } var locate = \''.plugins_url( 'locate.php', __FILE__ ).'\'; xmlhttp.open("GET", locate+"?search="+searchInput); xmlhttp.send(); </script> <textarea rows="15" cols="50" id="search"></textarea>
i have to import wp files to check for admin status/get_home_path() etc, which requires a static ‘../../../’ . This is because wp functions aren’t loaded by 2nd. Will looking Hooks, Actions and Filters solve this issue? if so could you point me to the function/s i should use. (yep, i plan i learn this in great detail as soon as i get some sleep)
Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Plugin uses ajax to call php function’ is closed to new replies.