Callign PHP program from Javascript?

by 3 replies
4
I have a little php program that reads a database
and creates ads

http://freeheadlinecreator.com/jackads.php

I want to be able to give people a little piece of
javascript code that they can out on any html page
on any domain and put the ads on their page

I tried this but it didn't work:

<script language="JavaScript" type="text/javascript"
src="http://freeheadlinecreator.com/jackads.php">
</script>

Any ideas?

Maybe I need a .js File?


Jack
#programming #callign #javascript #php #program
  • You can do this, but the php needs to generate javascript, not html. More specifically, you'll have to generate javascript that will write out the html you need.
  • To give an example of what Michael is talking about, if your PHP script outputs HTML like this...

    Code:
    <p>Click here for <a href="http://www.mysite.com">My Site</a></p>
    Then it will cause javascript errors. What you need the PHP file to output is more like this...

    Code:
    print ('<p>Click here for <a href="http://www.mysite.com">My Site</a></p>');
    As "print" is the javascript functon to display something on the page. Keep in mind that any apostrophe... ' in your code must be preceded with a backslash... \' or it will cause trouble.

    -Ryan
    • [1] reply

Next Topics on Trending Feed