You can write like this in JavaScript or jQuery Ajax and call the file
$('#btn').click(function(){_x000D_
$.ajax({_x000D_
url:'test.php?call=true',_x000D_
type:'GET',_x000D_
success:function(data){_x000D_
body.append(data);_x000D_
}_x000D_
});_x000D_
})
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>_x000D_
<form method='get' >_x000D_
_x000D_
<input type="button" id="btn" value="click">_x000D_
</form>_x000D_
_x000D_
<?php_x000D_
if(isset($_GET['call'])){_x000D_
_x000D_
function anyfunction(){_x000D_
echo "added";_x000D_
_x000D_
// Your funtion code_x000D_
}_x000D_
}_x000D_
?>
_x000D_