I have a jQuery script that I am including on a PHP page that takes mt content and creates facebook/myspace share links. I am having trouble echoing PHP code inside of the swith case statement that builds the share URL’s. Here’s my code:
case ‘facebook’:
this.href += ‘?t=’ + document.title + ‘&u=http://foobar.com/detail.php?id=’;
break;
The server isn’t parsing the PHP code correctly, it’s passing the value id=<?php echo "1";?> rather than 1. Can I not insert PHP code into a javascript include?
Option 1. In your file.php:
Option 2. create a PHP file that returns the javascript content type externalphp