Web Analytics Made Easy -
StatCounter Execute php page from javascript - CodingForum

Announcement

Collapse
No announcement yet.

Execute php page from javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Execute php page from javascript

    Originally posted by mlseim View Post
    hmmm .... sort of stumped.

    For a test, I made a script that pulls a random "bumper-sticker" quote
    out of a file and sends it back as Javascript.

    Put this on a test page of yours and see what happens:

    <script type="text/javascript" src="http://www.catpin.com/bumper_sticker3.php"></script>

    Wherever that line is, when you view your web page, it should have a random quote.

    It's using the same code that I had above (in post #2).
    how would you put <script type="text/javascript" src="http://www.catpin.com/bumper_sticker3.php"></script> into a function for javascript to call this php file?

  • #2
    I think it would have to be AJAX, a combination of PHP and javascripting.
    You may have to ask this in the javascript forum, as I'm not a javascript expert.


    .

    Comment


    • #3
      Moved.

      Comment


      • #4
        Since that PHP page returns actual JavaScript code (example, document.write("Is it time for your medication or mine?") , you need to simply drop that line you showed ANY PLACE in your page where you want the text to appear.

        Just as a simple example:
        Code:
        ....
        <span style="font-size: large; color: red;">
        <script type="text/javascript" src="http://www.catpin.com/bumper_sticker3.php"></script>
        </span>
        ...
        There are other, more eloquent ways to use content from PHP pages, but given what you already have there, this is about the only useful way to do it.
        Be yourself. No one else is as qualified.

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎