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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Location
    Israel
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Parameter passing from server side php to client side javascript

    Hi people,
    I need help as follows:

    On the server side I have a php generated session parameter.
    I need to pass it to javascript on the client side page.

    I saw on the web the following solution:

    <script language="JavaScript">
    var mySessionVar="<%= Session["MySessionVar"] %>";
    </script>

    I tried it but it did not work.

    I could not find any explanation of this syntax - will appreciate one.

    Any suggestions, maybe in another way?

    Thanks

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Long time ago I used PHP ... but <% is most definitely not PHP. Neither is Session[] which should be $_SESSION[] in PHP afaik.

    Try this:
    Code:
    var mySessionVar="<?=$_SESSION['MySessionVar']; ?>";


  •  

    Tags for this Thread

    Posting Permissions

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