Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Include .php file with javascript

    Hi

    I wanted to include a .php file but using javascript or anything else that can be called from a .html page. I am trying to call a php file from VBulletin header template file and I tried putting the include() fucntion from php but that didn't work so thats why I am looking for another way to call a .php file.

    Any help greatly appreciated.

    Thanks

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,043
    Thanks
    19
    Thanked 42 Times in 42 Posts
    why didnt the php include() work?
    javascript is actually executed on the wrong side to include, show your code with the include() function on, and show us whats inside the included page and what your expecting to happen
    thanks

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Aye, as rafiki mentioned, PHP is server-side; once the browser has the file PHP is done with it and Javascript can't do anything related to PHP. That's like trying to tighten a nut with a hammer.

    Read this:

    How PHP works

    Then you can begin to consider solutions to your problem (such as Ajax).

  • #4
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    You can use AJAX to dynamically call new files. How do you think this quick post works?

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    That was already stated...
    Quote Originally Posted by Fumigator View Post
    Then you can begin to consider solutions to your problem (such as Ajax).

  • #6
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Whoops totally missed that. What Fumigator said

  • #7
    New Coder
    Join Date
    Jan 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanx for the replies.

    Ok now when I try to put the include(''); function to call the php file all it does is out it like this
    include("/home/sitename/public_html/forums/header.php");
    it doesn't actually output it and show the tables etc. The file in which I m trying to include this php file is a template file .tmp and is actually stored inside mysql database, thats why I am looking for another way to include a php file.

    How can I do it with AJAX? is it possible?

  • #8
    New Coder
    Join Date
    Jan 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I got it using AJAX yayyy ..

    thankx alot though


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •