www.webdeveloper.com
Results 1 to 5 of 5

Thread: In a php file i can acces from javascript to the php variables but not functions

Threaded View

  1. #1
    Join Date
    Jan 2013
    Posts
    84

    Unhappy In a php file i can acces from javascript to the php variables but not functions

    I've an html file with php extension (index.php) and i use a mix of javascript and php code.
    The problem is that i'm unable to launch a php function from JS..

    this don't work
    PHP Code:
    <?php 
    function updateVideo(){
    //some code
    }?>

    <script>
    function aggiornaVideo(){
        <?php updateVideo(); ?>
    }

    </script>
    Yes, i know that PHP is a server side language while JS a client-side, but for what reason if i attempt to access to php variables along the document it's possibile such they are stored in memory while the same thing isn't possible with function?
    For exemple, this code normally retrieve me a variable from php

    PHP Code:
    <?php 
     $page
    =4
    //some code
    ?>

    <script>
    function aggiornaVideo()
    {
        var pro='<?php echo $page?>'
        alert(pro)
    }

    </script>
    Last edited by American horizo; 07-29-2013 at 11:52 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles