Can i call php file in Javascript file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hpandya
    New Member
    • Jan 2008
    • 9

    #1

    Can i call php file in Javascript file

    Can i call php file in Javascript file,?
    or
    how can call php functions in javascript file ?

    Please help me out here

    Thanks,
    Harsh
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #2
    Hi, and first off can i say I like your name!!!! I mean mine being harsh aswel!!!

    secondly back to business, how do you want to call the PHP, research a bit of ajax, you can submit a form to php using javascript, but it really depends on what you are trying to do

    Comment

    • hpandya
      New Member
      • Jan 2008
      • 9

      #3
      I have pop up in php file. I have fade in - fade out functions in that PHP file aswell. Working fine.

      But Now when i write this functions in .js file and call that file over in PHP file it still works fine.

      Now the problem is::::: I want to call this .js file functions (for my pop up) to another function inside the .js file. But when i do that its not working.

      I am using document.getEle mentById to get the pop up text from PHP file. I want to call this .js file functions (for my pop up) to another function inside the .js file. But when i do that its not working because when i use getElementByID .js file does not know where to find ID, which is in that PHP file. Remember i have already call the .js file in PHP file but it does not work.

      So i thought the only way is to call PHP file in .js file

      By the way my name is HARSH. In india it means JOY but Here in USA it means Cruel. But i am not cruel. My parents did not think that i will go to USA someday. Well i am not changing my name for this because i like it.

      Thanks in advance...
      Harsh
      India

      Comment

      • harshmaul
        Recognized Expert Contributor
        • Jul 2007
        • 490

        #4
        Hi again Harsh,
        You will need to post some code.

        but heres some provisional information....

        PHP files are held on the server, they respond to requests from browsers usually with html markup. Javascript is on the client machine and then cannot interact directly with PHP.
        you CAN get variables to javascript which can be used later on, on the client machine, but not the other way (well at least not without posting). please be careful not to fall in the trap of thinking variables can be passed two ways between javascript and PHP.

        I repeat my first statement again, please post as much code as you can so we can get a better idea of what you are trying to do.

        Finally, my name is Harjit, and in school people shortened that to Harj, and the one of my friends with a speach impediment couldn't say the "J" sound, as used to call me harsh, and it stuck, and i used it as a tag name when i used to DJ.

        Comment

        Working...