So I’ve set up AJAX with WordPress properly, having followed some good tutorials, and it’s working great. One thing I can’t quite work out is how to properly return either TRUE or FALSE from within the callback function.
My php function is as follows:
function my_callback() {
if(something()) {
echo 'false';
} else {
echo 'true';
}
exit;
}
In the JS do I simply do if(response == 'true') { // do something }
or is there a better way?
This might seem a little trivial but this is the first time I’m really using AJAX!
this would work to:
and in js: