gpt4 book ai didi

javascript - document.ready jquery 难度

转载 作者:行者123 更新时间:2023-11-28 12:45:41 27 4
gpt4 key购买 nike

在母版页中我有以下代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.js")" type="text/javascript"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@RenderBody()
</body>
</html>

然后在 Index.cshtml 中我有以下代码:

@{
ViewBag.Title = "Index";
}
<h2>
Index</h2>
<div data-role="page">
<div data-role="header">
...</div>
<div data-role="content">
<a id="btnShowCustomers" data-role="button" href="#secondDiv"></a>
</div>
<div data-role="footer">
...</div>
</div>
<div id="secondDiv" data-role="page">
<div data-role="content">
</div>
</div>
<script type="text/javascript">
(document).ready(function (event) {
$('#btnShowCustomers').bind('click', function (event) {
GetCustomers();
});
});

function GetCustomers() {
var webMethod = "Home/GetCustomers";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: webMethod,
data: "{}",
dataType: "json",
success: function (dataObj) {
alert('lala');
}
});
}
</script>

使用 Firebug 进行调试时出现以下错误:

document.ready 不是一个函数[中断此错误](文档).ready(函数(事件){

这怎么可能?文档准备好后,我想注册按钮的单击事件的处理程序。有什么建议吗?

最佳答案

(document).ready(function (event) {

应该是

$(document).ready(function (event) {

关于javascript - document.ready jquery 难度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7875156/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com