Why does my JS URL string's & get converted to #038; on some server setups?

182 Views Asked by At

I have a HTML select field with options and some JS which builds a URL and adds it as the value of the options:

  <script>
    $( document ).ready(function() {
      url = '';
      url += '?test=1'
      url += '&something=1' // Ampersand here becomes #038; on some hosts
      $( '#select option' ).val( url );
    });
    $( document ).on( 'change', '#select', function( e ) {
            window.location = $( this ).val();
        });
  </script>

  <select id="select">
    <option value="">Test</option>
    <option value="">Test</option>
  </select>

I've noticed at jsfiddle this works fine, but then when trying this locally it converts the ampersand in url to #038;

Why is this? As it's doing this it effects me getting $_GET['something'] via PHP when that option is selected

0

There are 0 best solutions below