[英]Variable not working with SPServices
我的变量有问题。 我不确定它是否与语法有关,但是由于某种原因,带有变量的if
语句的第一部分将无法工作。
我在没有SPServices
情况下对其进行了测试,如果我只是在没有SPServices
情况下进行了该功能,则它可以正常工作。 我还用警报而不是变量测试了SPServices
,它们也可以正常工作。 请查看下面的代码,我们将为您提供任何帮助。 谢谢!
$(document).ready(function(){
var dropdown = $("select[title='Item-Status']");
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function(xData, Status) {
if ($(xData.responseXML).find("Group[Name='CCB Team']").length == 0) {
dropdown.find("option[value='QA Review']").remove();
} else if ($(xData.responseXML).find("Group[Name='QA Team']").length == 1) {
alert("You should see this");
}
}
});
});
没关系。 我意识到我在函数要声明的函数之外声明了变量。 代码应这样写:
$(document).ready(function(){
$().SPServices({
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,
completefunc: function(xData, Status) {
var dropdown = $("select[title='Item-Status']");
if ($(xData.responseXML).find("Group[Name='CCB Team']").length == 0) {
dropdown.find("option[value='QA Review']").remove();
} else if ($(xData.responseXML).find("Group[Name='QA Team']").length == 1) {
alert("You should see this");
}
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.