I have a question regarding my portfolio website creaded with a wordpress theme. I want to call a function in a php file from a jquery script. But the php file is not responding. I am not sure if I call it the right way. I would like if someone can take a look at.
jQuery(document).ready(function($) {
$('#allbuttons').click(function(event){
$.ajax({url: 'wp-content/themes/scope/single-portfolio.php',
data: {action: 'test'},
type: 'post',
success: function(output) {
alert(output);
}
});
And this is the php:
<?php if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
echo "ACTIE!!!!";
switch($action) {
case 'test' :
echo "done!!";
break;
// ...etc...
}
} else {
echo "mislukt:(!!!!";
}?>
Maybe it is not a recommed way but i need to change the content which is currently being displayed which is being controlled in this php file. I also tried the accepted answer from: How can I call PHP functions by JavaScript?
But that also did not give me any response. I am not familair with both scripting languages.
Thank you in advance