我的变量有问题。我不确定它是否与语法相关,但是由于某种原因,我的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");
}
}
});
});发布于 2016-11-01 17:34:42
不要紧。我意识到在我想要使用它的函数之外声明了这个变量。代码应按如下方式编写:
$(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");
}
}
});
});https://stackoverflow.com/questions/40344173
复制相似问题