我真的可以提供一些帮助。我有两个使用ajax请求填充DOM的功能,并且我有一个定期更新加载的DOM的功能。
我有以下 Ajax GET 请求,这些请求在从Visual Studio运行时以及在本地计算机上的IIS v10上托管时都在本地计算机上运行。 **问题:**当我将此应用程序部署到具有以下IIS版本的Windows Server 2016的测试服务器时:Test server IIS version
应用程序和ajax请求在我的本地计算机(这是Windows 10计算机,其IIS版本为Windows 10 michine IIS version
)上可以正常工作这是一个 .NET Core 2.1 后端应用程序,使用Razor页面作为视图,我试图根据来自我的Ajax调用的响应用html填充标签,并定期更新其中的一些值填充的HTML。关于服务器IIS设置,我是否缺少某些东西?我的应用程序中需要特殊的配置吗?还是我错过了AJAX中的参数或其他东西?我添加了警报以进行测试,以了解在浏览器中查看时是否输入了AJAX。任何反馈将不胜感激。
'use strict';
$(function getType1DashboardItems() {
alert("Entered getType1DashboardItems ")
$.ajax({
type: 'GET',
async: true,
url: 'api/GetQuantumDashboardItemsAsync/Type1',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
cache: false,
success: function success(data) {
alert("Successfully called 'api/GetQuantumDashboardItemsAsync/Type1' in getType1DashboardItems ")
$.each(data.areas, function (i, area) {
//HTML for dashboard areas
var areaHtml = '<div id="dashboardArea-' + area.guid + '" class="area-card card col-sm-3 p-2"> ' +
'<div class="dashboard-heading"><strong id="areaHeading" class="area-heading">' + area.title + '</strong></div><hr class="heading-underline"/>' +
'<div id="areaDataSources-' + area.guid + '" class="card data-source-card"></div>';
$('#Type1Areas').append(areaHtml);
//dashboardItems array
var dashboardItems = area.dashboardItems;
getDataSources(area, dashboardItems);
});
},
complete: function complete() {
refreshDashboardItems("Type1");
},
error: function (xhr, textStatus, data) {
console.log('xhr: ' + xhr);
console.log('textStatus: ' + textStatus);
console.log('data: ' + data);
}
});
});
$(function getType2DashboardItems() {
alert("Entered getType2DashboardItems ")
$.ajax({
type: 'GET',
async: true,
url: 'api/GetQuantumDashboardItemsAsync/Type2',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
cache: false,
success: function success(data) {
alert("Entered getType1DashboardItems ")
$.each(data.areas, function (i, area) {
//HTML for dashboard areas
var areaHtml = '<div id="dashboardArea-' + area.guid + '" class="area-card card col-sm-3 p-2">' +
'<div class="dashboard-heading"><strong id="areaHeading" class="area-heading">' + area.title + '</strong></div><hr class="heading-underline"/>' +
'<div id="areaDataSources-' + area.guid + '" class="card data-source-card"></div>';
$('#Type2Areas').append(areaHtml);
//dashboardItems array
var dashboardItems = area.dashboardItems;
getDataSources(area, dashboardItems);
});
}, complete: function complete() {
refreshDashboardItems("Type2");
},
error: function (xhr, textStatus, data) {
console.log('xhr: ' + xhr);
console.log('textStatus: ' + textStatus);
console.log('data: ' + data);
}
});
});
function refreshDashboardItems(dashboard) {
$.ajax({
type: 'GET',
async: true,
url: 'api/GetQuantumDashboardItemsAsync/' + dashboard,
dataType: 'json',
contentType: 'application/json; charset=utf-8',
cache: false,
success: function success(dashboard) {
alert("Successfully called 'refreshDashboardItems for "+ dashboard.toString())
var dashboardTitle = dashboard.title;
$.each(dashboard.areas, function (i, area) {
var highestPriorityColour = ""
var monitorTargetPanelHeader = document.getElementById(dashboardTitle + "DropdownPanel");
$.each(area.dashboardItems, function (i, dashboardItem) {
var date = moment(dashboardItem.dataProviderHealth.dateLastAccessed).format('DD-MM-YYYY HH:mm:ss');
var dataSourceCountContainer = document.getElementById("data-source-count-" + dashboardItem.guid);
var dataSourcePartsContainer = document.getElementById("listOfParts-" + dashboardItem.guid);
var dataSourceLastAccessed = document.getElementById("dataSourceLastAccessed-" + dashboardItem.guid);
//DataSource parts are added to the parts list
var partsList = "";
$.each(dashboardItem.parts, function (i, part) {
var newPart = "<li class='part'>" + part.serialNumber + "</li>";
partsList += newPart;
});
dataSourceCountContainer.innerHTML = dashboardItem.count + " Files Pending";
dataSourcePartsContainer.innerHTML = partsList;
dataSourceLastAccessed.innerHTML = date;
var statusColour = dashboardItem.statusColour.toLowerCase()
if (statusColour == "red") {
highestPriorityColour = "red"
}
else if (statusColour == "orange" && highestPriorityColour != "red") {
highestPriorityColour = "orange"
}
});
if (highestPriorityColour != "") {
$(monitorTargetPanelHeader).removeClass(monitorTargetPanelHeader.className).addClass("k-link panel-bar-header-" + highestPriorityColour);
}
else {
$(monitorTargetPanelHeader).removeClass("panel-bar-header-red");
$(monitorTargetPanelHeader).removeClass("panel-bar-header-orange");
$(monitorTargetPanelHeader).addClass("k-link k-header");
}
});
},
complete: function complete() {
setTimeout($.proxy(refreshDashboardItems, this, dashboard), 10000);
},
error: function (xhr, textStatus, data) {
console.log('xhr: ' + xhr);
console.log('textStatus: ' + textStatus);
console.log('data: ' + data);
}
});
};
<html>
<body>
<div class="panels">
<ul id="panelbar">
<li id="Type2DashboardList" class="area k-state-active">
<span id="Type2DropdownPanel" class="k-link k-state-selected">Type2</span>
<div id="PanelBarContents" class="panel-bar-contents">
<ul id="Type2Areas" class="area-row row"></ul>
</div>
</li>
<li id="Type1DashboardList" class="area">
<span id="Type1DropdownPanel" class="k-link">Type1</span>
<div id="PanelBarContents" class="panel-bar-contents">
<ul id="Type1Areas" class="area-row row"></ul>
</div>
</li>
</ul>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.all.min.js"></script>
</body>
</html>
编辑:添加了来自开发工具的错误图片。 This is the error I get.
Here is the network headers for the request.-这是200个回答,这让我感到困惑。