views:

220

answers:

2

I am using jQuery session in my master page. Anything I'm missing?

Code:

<script type="text/javascript" language="javascript" src="js/jquery.js"></script>

<script type="text/javascript">
$(document).ready(function() {
  $.session("lnkID","A1")
});                   
</script>

Error:
Microsoft JScript runtime error: Object doesn't support this property or method

+1  A: 

By your example alone, you're missing a reference to the required files, and you're not wrapping your jQuery code in script tags. You need to reference not only jquery-source, but jquery-json, and jquery-session as well.

<script type="text/javascript" src="scripts/jquery.js"></script> 
<script type="text/javascript" src="scripts/jquery.json.js"></script> 
<script type="text/javascript" src="scripts/jquery.session.js"></script>

Once you've got those in place, you need to place your logic within script tags:

<script type="text/javascript">
$(function(){
  $.session("foo", "bar");
});
</script>

See the following demo for an example: http://www.jaysalvat.com/session/test1.html

Lastly, the language attribute of the script tag is deprecated. You can do away with it, but keep the type attribute.

Jonathan Sampson
A: 

I keep getting a forbidden message when I try to hit the jQuery session link on code.google. Am I missing something?

John