asp.net mvc jquery问题(0x800a1391 - JavaScript 运行时错误: “$”未定义)
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<script src="~/Scripts/jquery-1.9.1.js"></script>用这句就有问题(此文件我已经下载到这个目录里面)
@*<script src="http://code.jquery.com/jquery-1.9.1.js"></script>*@ 用这句就没问题
<head>
<title>Index</title>
</head>
<script type="text/javascript">
function Test() {
$.ajax({
url: "/Home/GetJson",
type: "Get",
dataType: "JSON",
success: function (data) { alert(data.Name); }
});
}
</script>
<body>
<div>
姓名:<input id="txtName" type="text"/><br />
年龄:<input id="txtAge" type="text" value="1"/><br />
<input type="button" id="btnSubmit" value="JSON交互" onclick="Test()"/>
</div>
</body>
</html>
------解决方案--------------------<script src="@Url.Content("~/Scripts/jquery-1.9.1.js")" type="text/javascript"></script>