title: Removing white-space in AJAX response
body: <p>I have a php script which returns <code>0.28</code>. This is then fetched to HTML using AJAX, and inserted into a span. The problem is, it is inserted with 5 spaces and what appears to be a newline. jQuery then sees that as a change and updates the existing span with the new value when there is no change. It appears that the whitespace does not come from the php. I have tried:</p>
  
  <ul>
  <li>to trim() and ltrim() the php to get rid of whitespace</li>
  <li>remove php exit tag</li>
  <li>white-space-collapsing: discard; in the css and using the !important tag
  (this is not being read and the chrome yellow alert is on it)</li>
  <li>trimming the response with jquery</li>
  <li>using html notes to cut the space</li>
  </ul>
  
  <p>Dumping the php variable:</p>
  
  <pre><code>string(4) "0.28"
  </code></pre>
  
  <p>This is how my browser returns it</p>
  
  <pre><code>   &lt;span id="response1" style="display: inline;"&gt;*5spaceshere*    
     0.28&lt;/span&gt;
  </code></pre>
  
  <p>This is my script</p>
  
  <pre><code>$(function () {
      function update() {
          $.ajax({
              type: "GET",
              url: "balancefetch.php",
              dataType: "html",
              success: function (response) {
                  var trimmedResponse = $.trim(response)
                  if (trimmedResponse != $("#response1").html()) {
                      $("#response1").fadeOut(200, function () {
                          $("#response1").html(response);
                          $("#response1").fadeIn();
                      });
                  } else {}
              }
  
          });
      }
      setInterval(update, 5000);
      update();
  });
  </code></pre>
  
  <p>And my html</p>
  
  <pre><code>&lt;div id="balance-div"&gt;&lt;!--
  --&gt;&lt;p class="balance"&gt;Balance&lt;span id="response1"&gt;Loading...&lt;/span&gt;&lt;/p&gt;&lt;!--
  --&gt;&lt;/div&gt;
  </code></pre>
  
  <p>php</p>
  
  <pre><code>$balance = ltrim($balance);
  echo $balance;
  </code></pre>
  
  <p><code>$balance</code> holds 0.26</p>