开发者

JQuery Session problem

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>
开发者_JAVA技巧

Error:

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜