I have this in my JavaScript part:
$.post(
WPaAjax.ajaxurl,
{
action : 'my_php_action_to_do',
},
function( response ) {
alert( response.mycode );
}
);
and this in my my_php_action_to_do
php function:
function my_php_action_to_do() {
$send_to_response['mycode'] = '1234';
echo json_encode( $send_to_response );
exit();
}
I can execute the php code in the php function and run the result post javascirpt code, but the problem I am facing is how to send the variable from the php function back to response and alert it or use in whatever way.
Now I am getting undefined
in a popup window as a result.
How to do that in WordPress?