2016-10-31 2 views
0

私の変数に問題があります。文法に関連しているかどうかは分かりませんが、何らかの理由で私の変数であるif文の最初の部分がうまくいきません。変数がSPServicesと連携していません

私は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"); 
      } 
     } 
    }); 
}); 

答えて

0

心配しないでください。私は、関数の外で変数を宣言していることに気がつきました。コードは次のように記述する必要があります。

$(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"); 
      } 
     } 
    }); 
}); 
関連する問題