我有一个工作得很好的JavaScript文件,除了它没有返回一个字段。它们全部来自SharePoint列表,它显示为“未定义”但我认为我在开始时定义了它?
返回的信息显示在HTML pafe
上我遇到问题的变量是'var txtfurtherinfo ="";'
?其他一切都很好。任何帮助表示赞赏。 JavaScript在下面,它后来称为DeviceInformation ...
function getDeviceDetails() {
var txtTitle = "";
var txtName = "";
var txtOverview = "";
var txtAccessories = "";
var txtDevicetype = "";
var txtTypicalDeviceUsage ="";
var txtKnownSystemIssues ="";
var txtTrafficlight = "";
var imgDevicePicture = "";
var tempLCS2 = "";
var txtfurtherinfo ="";
var HTML = "<h3>Desktop</h3>";
var Laptop = "Y"
var Tabs="Y"
var query = "http://example.com/sites/it/ITInfrastructure/_vti_bin/listdata.svc/Devices?$expand=Priority&$filter=Id eq " + window.DeviceId + "";
var call = $.ajax({
url: query,
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
}
});
call.done(function (data,textStatus, jqXHR){
$.each(data.d.results, function(index, item) {
var tempID = item.Id;
var NameofDevice = item.Title;
var tempTitle = item.Title;
var DeviceOverView = item.Description;
var AccessDetails = item.Accessories;
var DeviceKind = item.DevicetypeValue;
var Usage = item.TypicalUsage;
var DevicePriority = item.PriorityValue;
var DeviceImage = item.DeviceImage;
var DeviceInformation = item.furtherinfo;
txtTitle = "<p>" + NameofDevice + "<p>";
txtName = "<p>" + NameofDevice + "</p>" + DeviceKind + "</p>";
txtOverview = "<p>" + DeviceOverView + "</p>";
txtAccessories = "<p>" + AccessDetails + "</p>";
txtDevicetype = "<p>" + DeviceKind + "</p>";
txtTypicalDeviceUsage = "<p>" + Usage + "</p>";
txtTrafficlight = "<p>" + DevicePriority + "</p>";
txtfurtherinfo ="<p>" + DeviceInformation + "</p>";
imgDevicePicture = "<img src='" + DeviceImage + "'>";
});
$('#devicedetails').append($(txtTitle));
$('#deviceoverview').append($(txtOverview));
$('#devicetitle').append($(txtTitle));
$('devicename').append(txtName);
$('#devicekind').append(txtDevicetype);
$('#deviceacc').append(txtAccessories);
$('#deviceuse').append(txtTypicalDeviceUsage);
$('#devicestatus').append(txtTrafficlight);
$('#furtherinfo').append(txtfurtherinfo);
$('#imageContainer').append("<img src='/sites/IT/ITInfrastructure/SiteAssets/"+txtTrafficlight.replace(/<[^>]*>/g, '')+".png' />");
$('.deviceimage').append(imgDevicePicture);
});
call.fail(function (jqXHR,textStatus,errorThrown){
alert("Error retrieving data: " + jqXHR.responseText);
});
}
答案 0 :(得分:0)
在javascript中未定义的很多次是当您尝试访问范围中未定义的信息时。 您的item变量可能没有任何名为“Furtherinfo”的成员变量。 基于其他成员变量的表示法,它可以被称为“FurtherInfo”,“FurtherInfo”或类似的东西。