title: Javascript and jquery if function is not working
body: <p>Help me!
  I have this kind of code but it never goes to IF function?
  What is wrong?
  jquery is working but does alert kill IF funtion?
  IF funtion is working without jquery.</p>
  
  <pre><code>$.get("www.example.com", function(data) {
      var param = 'name'
      param = param.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
      var regex = new RegExp("[\\?&amp;]" + param + "=([^&amp;#]*)"),
          results = regex.exec(data);
      var paramValue = results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
      alert(paramValue);
  });
  
  if (name == 'Bob') {
      window.location = ("www.example.com");
  } else {
      window.location = ("www.example.com");
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Hi here is the right code but I changed URL addresses. 
  When I put <code>});</code> outside the <em>if/else</em> funtion it still doesn't work.</p>
  
  <p>It will so "<em>ketju</em>" information right but it doesn't go any www.example after that. </p>
  
  <p>So If/else is not working. I need this "ketju" information when user sign in to the website. I don't need to show this information just need to guide user to the right address. So this alert is not important. </p>
  
  <p>Every user have interface information which contain lot of information about user. </p>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $.get( "https://xxx.xx/learning/id2/bin/flash_api2?random=", 
  function( data ) {
  var param = 'ketju'
  param = param.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  var regex = new RegExp("[\\?&amp;]" + param + "=([^&amp;#]*)"),
  results = regex.exec(data);
  var paramValue = results == null ? "" : 
  decodeURIComponent(results[1].replace(/\+/g, " "));
  alert( paramValue );
  
  
  if (ketju == 'Sweden') {    
  window.location=("www.example.com");
   }else{
  window.location=("www.example.com");
  }
  });
  &lt;/script&gt;
  </code></pre>