So basically, I wrote an AJAX call that runs a PHP script that echoes hello world in response to a button click (handled by JS). I get status 200 and in the response section of my browser's "inspect element" function, I get "Hello world", but it doesn't display it on the page. I know that "echo" should work because I've used it to indicate that my site has connected to a MySQL database correctly. So the response section shows "Connected SuccessfullyHello World" (sic) but the page only displays "Connected Successfully". So for some reason, it's not actually showing that Hello World bit.
PHP
function test() {
echo "Hello World";
die();
}
JS
function yes(){
jQuery.ajax({
url: ajaxurl,
data: {
'action':'test_function'
},
});
};
Apologies in advance if the answer is ridiculously simple - I'm new to web development
Further info: using X theme (WP)
wp_ajax_
andwp_ajax_nopriv_
. if not please check the doc codex.wordpress.org/Plugin_API/Action_Reference/…