calling php function in javascript

Discussion in 'PHP' started by getquicksolution, Apr 22, 2010.

  1. #1
    How can we call a php function in javascript and pass javascript variable to it??????
     
    getquicksolution, Apr 22, 2010 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,901
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    The only way to do this is via AJAX. I'm not sure you understand the difference between server side processing and client side processing.

    Javascript is client side processing - it happens once the code has reached the user's browser. The only way it can call PHP, which is on the server, is by submitting a form or making a request back to the server.

    In the days before AJAX I had a technique for fudging it but nowadays you are much better off choosing an AJAX library (such as prototype, but there are others) and learning how to use it.
     
    sarahk, Apr 22, 2010 IP
  3. getquicksolution

    getquicksolution Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your quick reply and nice reply.
     
    getquicksolution, Apr 23, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    I'd suggest jQuery as its well documented, you'll find some good examples to get your started if you search in the right places.
     
    danx10, Apr 24, 2010 IP