 <p>No, it's not possible to execute PHP code in Javascript. </p> <p>What you'll need to do is make an ajax query to a php page. You can get more information about how to do that here: <a href="http://www.w3schools.com/php/php_ajax_xml.asp" rel="nofollow">http://www.w3schools.com/php/php_ajax_xml.asp</a></p> <p>And more info about XMLHttpRequest: <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest" rel="nofollow">https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest</a></p>