Reputation: 107
i failed to pass the value to my script, anyone can tell me what is my mistake ?
output
Microsoft JScript runtime error: '$' is undefined
my javascript function
function setSessionValue(key, value) {
$.post('setSession.aspx?key=' + key + '&value=' + value);
}
button to call for function
asp:LinkButton ID="lnkname" runat="server" Text='<%#Eval("movieTitle") %>' Width='500px'
CommandName="cmdLink" PostBackUrl='~/videotest.aspx'`
OnClientClick="setSessionValue('itemID','3345');"
Upvotes: 0
Views: 505
Reputation: 8232
Also make sure you have imported jquery first before any scripts using it.
Upvotes: 0
Reputation: 9680
The most probable reason would be,
$
syntax before importing the jQuery.The syntax should look like this
<script type="text/javascript" src="SOURCE OF YOUR JQUERY.JS FILE">
<script type="text/javascript">
function setSessionValue(key, value) {
$.post('setSession.aspx?key=' + key + '&value=' + value);
}
</script>
Hope this helps you.
Upvotes: 0
Reputation: 30648
have you included jquery js files in your page?
<script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>
Upvotes: 2