How would I go about executing a php-script from a javascript-function?
<?php if ( isset( $results['errorMessage'] ) ) { ?>
<script type="text/javascript>somemethod(<?php echo $results['errorMessage'] ?>) </script>
<?php } ?>
Sorry for the bad formatting – not sure how to use code in this editor :S
You need to make an HTTP REQUEST from JavaScript to call a remote PHP page/script.
The way you are trying to do it is not possible at all.