Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

messing about with a bit of php and java script

Options
  • 30-05-2012 2:00pm
    #1
    Registered Users 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 Posts: 760 ✭✭✭mach1982


    I figure how to do this, use AJAX


  • Registered Users Posts: 12,342 ✭✭✭✭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 Posts: 650 ✭✭✭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