I have created a WordPress page that has this simple PHP code:
<?php
$result = array(
'State' => 'Done',
'ID' => 1
);
wp_send_json( $result );
?>
When submitting a form in another page using Ajax(JQuery) it calls this PHP page, then in the JQuery method i try to read the returned value from the PHP page using this code:
$( '#contact_form' ).bootstrapValidator({
fields: {
// ...
},
submitHandler: function( formInstance ) {
$.post( "../send-message", $("#contact_form").serialize(), function( result ) {
alert( result );
});
}
});
But it actually returns the whole PHP page with its WordPress theme code used in addition to the passed parameters, as shown here:
My question is: How can i return a PHP value from a WordPress page to a JQuery function?
