title: Javascript encodeURIComponent() not encoding spaces
body: <p>I have a form with a text input with an id <strong>txtPlace</strong> that users will be entering input into that will be passed to the server as a url query. I'm trying to use encodeURIComponent(), but it is not encoding spaces. Here's my simplified code</p>
  
  <pre><code>&lt;div class="searchBoxRow"&gt;
    &lt;input type="text" id="txtPlace" size="55" placeholder="Enter place to search"/&gt;
    &lt;a href="#" id="btnSearch"&gt;Search&lt;/a&gt; 
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is my javascript</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    $(function () {
       $('#btnSearch').on('click', function (e) {
          e.preventDefault;
          var place = encodeURIComponent($('#txtPlace').val());
          var url = "http://example.com?place=" + place;
          document.location.href = url;
       });
    });    
  &lt;/script&gt;
  </code></pre>
  
  <p>If a user types <strong>ACME Co.,New York, NY</strong>, the generated url is </p>
  
  <blockquote>
    <p><a href="http://example.com?place=ACME" rel="noreferrer">http://example.com?place=ACME</a> Co.%2CNew York%2C NY</p>
  </blockquote>
  
  <p>See the spaces are unencoded? I even tried to add <code>place = place.replace(/\s/g, '+')</code> but that doesn't seem to work after encoding. What am I doing wrong? Thanks for your assistance.</p>
  
  <h2>Update:</h2>
  
  <p><strong>Blame Firefox!</strong> Found out that the spaces were being properly encoded but <strong>Firefox</strong> is not displaying spaces as encoded even though they are. Tested in <strong>Internet Explorer 10</strong> and <strong>Google Chrome</strong> and they both display spaces in their encoded format. Thanks Adam for the fiddle <a href="http://jsfiddle.net/VYDcv/" rel="noreferrer">http://jsfiddle.net/VYDcv/</a> </p>