我的变量有问题。我不确定它是否与语法有关,但是由于某种原因,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");
}
}
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句