我在一个简单的jQuery测试中遇到一个错误。请查看图像,以显示文件加载的顺序以及jQuery在错误发生之前加载的事实。
这是我的内容页:
<asp:Content
ID="Content1"
ContentPlaceHolderID="HeadContent"
runat="server">
</asp:Content>
<asp:Content
ID="Content2"
ContentPlaceHolderID="MainContent"
runat="server">
<textarea id="txtArea"> hi </textarea>
<script type="text/javascript">
// Shorthand for $( document ).ready()
$(function () {
$('txtArea').val = "bye";
});
</script>
</asp:Content>
我在母版页的末尾、结束标记之前加载了脚本。
有人知道是什么导致了这个简单的错误吗?
我不认为我的图像正在上传。下面是显示库已加载的firebug结果。
GET TestFolder/TestLoadingScriptsFromDifferentFolderLevel.aspx [HTTP/1.1 200 OK 1351ms]
GET Styles/Site.css [HTTP/1.1 200 OK 4ms]
GET WebResource.axd [HTTP/1.1 200 OK 351ms]
GET http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js [HTTP/1.1 200 OK 405ms]
GET http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.3/jquery-ui.min.js [HTTP/1.1 200 OK 417ms]
GET http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.3/themes/le-frog/jquery-ui.css [HTTP/1.1 200 OK 338ms]
GET http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.3/themes/mint-choc/jquery-ui.css [HTTP/1.1 200 OK 285ms]
GET http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js [HTTP/1.1 200 OK 394ms]
GET http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js [HTTP/1.1 200 OK 380ms]
GET http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js [HTTP/1.1 200 OK 419ms]
GET http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css [HTTP/1.1 200 OK 61ms]
GET http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables_themeroller.css [HTTP/1.1 200 OK 57ms]
GET http://ajax.aspnetcdn.com/ajax/knockout/knockout-3.0.0.debug.js [HTTP/1.1 200 OK 129ms]
ReferenceError: $ is not defined TestLoadingScriptsFromDifferentFolderLevel.aspx:45
GET WebResource.axd [HTTP/1.1 200 OK 2ms]