Javascript变量查询返回[object]
我有一个JavaScript文件,它正在查询SharePoint列表。我正在查询两个下拉列表。第一个-LifeCycleStatus-返回正常,但优先级下拉列表返回[object]。我认为这与var查询字符串有关。我已经在var查询中添加了“Priority”列,但它似乎没有任何区别Javascript变量查询返回[object],javascript,json,sharepoint-2010,Javascript,Json,Sharepoint 2010,我有一个JavaScript文件,它正在查询SharePoint列表。我正在查询两个下拉列表。第一个-LifeCycleStatus-返回正常,但优先级下拉列表返回[object]。我认为这与var查询字符串有关。我已经在var查询中添加了“Priority”列,但它似乎没有任何区别 var query = "http://collaboration- de.vxxx.com/sites/it/SystemInventory/_vti_bin/listdata.svc/Devices?$
var query = "http://collaboration-
de.vxxx.com/sites/it/SystemInventory/_vti_bin/listdata.svc/Devices?$expand=LifeCycleStatus&Priority&$filter=Id eq " + window.DeviceId + "";
全文如下:
function getDeviceDetails() {
var txtTitle = "";
var txtOverview = "";
var txtAccessories = "";
var txtDevicetype = "";
var txtTypicalDeviceUsage ="";
var txtKnownSystemIssues ="";
var txtLifeCycles = "";
var txtTrafficlight = "";
var tempLCS2 = "";
var query = "http://collaboration-dev.xxx/sites/it/SystemInventory/_vti_bin/listdata.svc/Devices?$expand=LifeCycleStatus&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 tempTitle = item.Title;
var LifeCycleStart = item.DeviceAvailableFrom;
var LifeCycleStatus = item.LifeCycleStatusValue;
var DeviceOverView = item.Description;
var AccessDetails = item.Accessories;
var DeviceKind = item.Devicetype;
var Usage = item.TypicalUsage;
var DevicePriority = item.Priority;
txtTitle = "<p>" + LifeCycleStart + "</p><p>" + LifeCycleStatus + "</p>";
txtOverview = "<p>" + DeviceOverView + "</p>";
txtAccessories = "<p>" + AccessDetails + "</p>";
txtDevicetype = "<p>" + DeviceKind + "</p>";
txtTypicalDeviceUsage = "<p>" + Usage + "</p>";
txtTrafficlight = "<p>" + DevicePriority + "</p>";
// txtKnownSystemIssues = "<p>" + KnownSystem + "</p>"
});
$('#devicedetails').append($(txtTitle));
$('#deviceoverview').append($(txtOverview));
$('#devicekind').append(txtDevicetype);
$('#deviceacc').append(txtAccessories);
$('#deviceuse').append(txtTypicalDeviceUsage);
$('#devicestatus').append(txtTrafficlight);
});
call.fail(function (jqXHR,textStatus,errorThrown){
alert("Error retrieving data: " + jqXHR.responseText);
});
函数getDeviceDetails(){
var txtTitle=“”;
var txtOverview=“”;
var txt=”;
var txtDevicetype=“”;
var txtTypicalDeviceUsage=“”;
var txtnownsystemissues=“”;
var txtLifeCycles=“”;
var txtrafficlight=“”;
var tempLCS2=“”;
变量查询=”http://collaboration-dev.xxx/sites/it/SystemInventory/_vti_bin/listdata.svc/Devices?$expand=LifeCycleStatus&Priority&$filter=Id eq“+window.DeviceId+”;
var call=$.ajax({
url:query,
键入:“获取”,
数据类型:“json”,
标题:{
接受:“application/json;odata=verbose”
}
});
call.done(函数(数据、文本状态、jqXHR){
$。每个(数据d.结果、功能(索引、项目){
var tempID=item.Id;
var TENTITLE=项目名称;
var LifeCycleStart=item.DeviceAvailableFrom;
var LifeCycleStatus=item.LifeCycleStatusValue;
var DeviceOverView=项目说明;
var AccessDetails=项目附件;
var DeviceKind=item.Devicetype;
var用法=item.TypicalUsage;
var DevicePriority=项目优先级;
txtTitle=“”+LifeCycleStatus+”“+LifeCycleStatus+””;
txtOverview=“”+设备概览+””;
txtAccessories=“”+AccessDetails+””;
txtDevicetype=“”+DeviceKind+””;
txtTypicalDeviceUsage=“”+用法+””;
txtrafficlight=“”+设备优先级+””;
//txtnownsystemissues=“”+KnownSystem+”“
});
$(“#设备详细信息”)。追加($(txtTitle));
$('#deviceoverview')。追加($(txtOverview));
$(“#设备种类”).append(txtDevicetype);
$(#deviceacc')。附加(txt附件);
$(“#设备使用”).append(txtTypicalDeviceUsage);
$(“#设备状态”).append(txtrafficlight);
});
call.fail(函数(jqXHR、textStatus、errorshown){
警报(“检索数据时出错:+jqXHR.responseText”);
});
}“优先级”和“生命周期状态”包含一个对象。您可以使用调试器/控制台查看对象是什么-我打赌它包含一个带有值的字符串,以及值的内部ID,可能还有其他内容。将对象转换为字符串将返回“[object]”
“PriorityValue”和“LifeCycleStatusValue”可能是值字符串的缩写。因为获取的值是一个对象,当您尝试将对象转换为字符串时,使用
。toString
方法返回[对象对象]
这很奇怪,因为它会返回LifeCycleStatus下拉列表结果。您建议Rajesh做什么?记录值并访问正确的属性抱歉,我不知道这意味着什么