<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
// when the document has finished loading, get the data
$(document).ready(GetData());
function GetData() {
$.ajax({
beforSend: function () {
$('#loadingDiv').css('display', 'block')
},
complete: function () {
$('#loadingDiv').css('display', 'none')
},
type: "GET",
url: "/Integrationsonify/Data.aspx",
data: dataObject,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var header = $("#accordion");
$.each(data, function () {
header.append("<a href='javascript:toggleDiv();'>" + this.Name + " </a>", "<div id='myContent' style='display:none'>" + "<ul>", "<li>" + this.Id + "</li>", "<li>" + this.SName + "</li>", "</ul>" + "</div");
});
},
error: function () {
alert("There was an error while rendering the page. Please contact the Admin for details");
}
});
}
function toggleDiv() {
$("#myContent").toggle();
}
</script>
<div id="loadingDiv" style="display: block;">
hi
</div>
<div id="accordion">
</div>
我无法切换 myContent div ..是因为它是在 ajax 调用中创建的吗?显示了 div,但是如果我为页面做一个查看源,我在手风琴 div 中看不到任何数据..但是在浏览器的 ui 端,我至少可以看到数据..谢谢,我很抱歉,我知道它是非常基本的问题,但我现在需要尽快找到解决方法,所以请指导我......