【发布时间】:2012-05-23 13:40:30
【问题描述】:
我对 jQuery 还很陌生,不知道什么是行不通的。
在以下示例中,当页面是 asp Web 应用程序的一部分时,代码可以正常工作。
但是当我在 IIS 中创建一个正常的网站时,负载不起作用。事件引发(通过警报尝试)但没有加载任何内容。
我假设 jScript ( jQuery ) 是独立的表单宿主机制。我错了吗?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="../../Scripts/jquery-1.5.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#MyButton').click(function () {
//Load HTML from HelpDetails.html
$('#OutputDiv').load('../HelpDetails.html #SubTOC');
});
});
</script>
</head>
<body>
<button id="MyButton">Click to Get HTML</button>
<div id="OutputDiv"></div>
</body>
</html>
【问题讨论】:
-
1. 您在控制台中看到了什么? 2. jQuery 加载是否正确?
-
jQuery 在 DOM 上工作,因此使用的服务器端技术没有实际意义。您在控制台中看到任何错误吗?
-
是否正在发出 AJAX 请求?服务器给出什么响应?您至少需要进行一些调试。
标签: jquery jquery-load