title: How to parse the querystring parameters in jquery when one of the param is having a special (&) character in its value
body: <p>I have a URL with some querystring.</p>
  
  <p>/mypage.html?errorcode=12345&amp;name=something &trade;</p>
  
  <p>I have a working code which can parse the querystring using jquery. But for the above example it is failing.</p>
  
  <p>Any ideas on this so I can get the querystring pairs as:
  errorcode = 12345 and 
  name = something &trade;
  Note: &trade; has (&amp;) in it. <br/>
  My code:</p>
  
  <pre><code>    $.extend({
          getUrlVars: function () {
              var vars = [], hash;
              var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');
              for (var i = 0; i &lt; hashes.length; i++) {
                  hash = hashes[i].split('=');
                  vars.push(hash[0]);
                  vars[hash[0]] = hash[1];
              }
              return vars;
          },
          getUrlVar: function (name) {
              return $.getUrlVars()[name];
          }
      });
  </code></pre>
  
  <p>var paramValue = $.getUrlVar('errorcode');</p>