Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

messing about with a bit of php and java script

  • 30-05-2012 02:00PM
    #1
    Registered Users, Registered Users 2 Posts: 760 ✭✭✭


    I'm messing about with a bit of php and java script. when someone click on the button it run a some php code. I test with just using echo hello so I though I replace the code with the php include function.
    But it is not work, is there something I am doing wrong ?
    <!DOCTYPE html>
    <html>
    <head>
    <script type="text/javascript">
    function rss()
    {
    //var php ="<?php echo 'hello'; ?>";
    var php ="<?php include (rss3.php); ?>";
    document.write(php);
    }
    </script>
    </head>
    <body>
    
    
    
    <button type="button" onclick="rss()">Rss feed</button>
    
    </body>
    </html>
    
    


Comments

  • Registered Users, Registered Users 2 Posts: 760 ✭✭✭mach1982


    I figure how to do this, use AJAX


  • Registered Users, Registered Users 2 Posts: 12,349 ✭✭✭✭starlit


    You need to add in php code into your file or a separate PHP file and link them into your HTML/Javascript file.

    I think you may have placed the <? in the incorrect position. Don't think the Doctype line is done correctly that is my opinion, its been a while since I coded PHP and HTML since college but could spot that line may or may not be done correctly.

    I haven't coded in Ajax but maybe look into that.


  • Registered Users, Registered Users 2 Posts: 668 ✭✭✭Freddio


    var php ="<?php include ('rss3.php'); ?>";


    you should call up rss3.php in your browser to see if it is correctly echoing something aswell

    if rss3.php isnt on the same server as this php file then it wont work with an include either


Advertisement