When I start my project and it loads up my page, I get the following error:
0x800a138f - JavaScript runtime error: The value of the property '$' is null or undefined, not a Function object.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="WebsiteTest.TestPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Web Service Test</title>
<script src="http://ajax.microsoft.com/ajax/jQuery/jquery-2.1.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#tbDetails').hide();
$('#btnClick').click(function () {
alert('test');
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<input type="button" id="btnClick" value="Get Data" />
<table id="tbDetails">
<thead style="background-color: #DC5807; color: White; font-weight: bold">
<tr style="border: solid 1px #000000">
<td>Description</td>
<td>Comments</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</form>
</body>
</html>
I'm assuming, it's got something to do with JQuery not being included even though it should be.
Any idea what the problem might be?
Thanks.
Update:
Works when using
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
Will keep researching it as to why it won't work with the MS one! It is definitely there as I can download it!
Update
I figured out 2 problems:
I was using https on my localhost and I should have used the https of jquery. Changing this got rid of my original error but it gave me some other error that I'm still researching.
My code works perfectly (and more since I've open this thread) as now I'm also calling a REST web service and manipulating the data returned without a single error but this only works in Chrome and Firefox! What the hell is up with IE11
Drop the protocol from the src and the browser will then use whatever your page uses. Here is an example
<script src="//ajax.microsoft.com/ajax/jQuery/jquery-2.1.1.js" type="text/javascript"></script>
Add this meta tag in your head. I was having same problem and I solved it by this
<meta http-equiv="X-UA-Compatible" content="IE=edge;" />
Have you tried extracting whole js code into separate file and then using it on your website using ClientScriptManager.RegisterClientScriptBlock?
I have't found the answer to this very annoying problem so I am adding my solution (which may not be the only one, but here goes).
If your physical folder path includes an underscore, it will fail to load jQuery. So, if you dropped your website to lets say C:\MyRoot\MyFolder_2\WebSite1\
then it won't work. However, if you remove the underscore and it becomes C:\MyRoot\MyFolder2\WebSite1\
it will work and jQuery will suddenly be loaded. jQuery loaded = no more errors.
Hope this helps
User contributions licensed under CC BY-SA 3.0