0

how to get value of session["new"] in java script function.

<script type="text/javascript">  
        jwplayer("container").setup({  
            flashplayer:'jwplayer/player.swf',
            file:'Video/Baby.FLV',  //How to set session["new"] value as file value.
            height:470,  
            width:320  
        });  
        </script>

i have the song file-name in session["new"], got it from another page.

can anyone tell me how to set file name in java script?

2 Answers 2

3

You can't read or write a server-side value (session-state) directly from the client-side. Setting a cookie, however, would work (since a cookie can be shared between client and server, and can be manipulated by the client-side code). You may find jquery-cookie useful.

Sign up to request clarification or add additional context in comments.

Comments

2

are you using asp.net? you should be able to do like file:<%=Session["new"]%>

1 Comment

I'm assuming he'll probably want to JSON encode that too... not sure what the proper syntax in 'vanilla' asp.net is, but with MVC3+Razor you'd do something like var session = @Html.Raw(Json.Encode(Session["new"])); i.e., to pass a C# variable into a JS variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.