Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

210
Visualizações
href link to js and validate user's profile to visit url

I have html href and linked to a function in js file. From the html when user clicked, it will validate user's profile by country. If the user's profile= TH and SG it will open a url, else it will open b url. Please help me. I do not know whats wrong with my code

    /* API Completion */
    api.done(function (a, c, d) {
   
      console.log(a.d);

      
      var countryCode = "";

      function checkCountry(upp) {
        return upp.Key === "CountryCode";
      }

      var arrUPP = a.d.UserProfileProperties.results.filter(checkCountry);
      
      //btn.addEventListener("click", travel);
      $(document).ready(function()
      {
        //$('ul.nav li').click(function() 
            
          if (arrUPP.length > 0 && arrUPP[0].Value) {
            countryCode = arrUPP[0].Value;
          }

          else if (countryCode == "TH" && countryCode == "SG") {
            window.location.href = 'https://....a url';
       

          } else {
            window.location.href = 'https://....b url';
            return;
          }
      
      });
    //} 
  });
  api.fail(function (a, b, c) {
    var errorMessage = [];
    errorMessage.push(errorMessage);
    errorMessage.push("Error: " + a.responseJSON.error.message.value);

    alert(errorMessage.join("\n"));
  });
  
<li class="main">
        <a class="travel" href="javascript:travel();"  target="blank">
           <i class="icon-travel"></i>
     <span>Country</span>
        </a>
    </li> 

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This will never be true countryCode == "TH" && countryCode == "SG". You expect one value to be both "TH" AND "SG". You probably meant to use ||.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda