title: Why does jquery $.ajax remove line breaks in data and $.get doesn't?
body: <p>I call the same PHP script using $.ajax and $.get and get two different results. </p>
  
  <p>$.ajax strips line breaks from data passed through the function while $.get doesn't. </p>
  
  <p>I've tried explicitly setting the dataType to text and html with no luck. Most of the parameters for $.get default to the same in $.ajax.</p>
  
  <p><a href="http://api.jquery.com/jQuery.ajax/" rel="noreferrer">http://api.jquery.com/jQuery.ajax/</a></p>
  
  <p>Is this a bug? </p>
  
  <p>Here is the exact code I use:</p>
  
  <pre><code>    $.get("lib/ajax_scripts/set-product-value.php", { input_id: input_id, val:value });
  
      $.ajax({
              url:"lib/ajax_scripts/set-product-value.php",
              type:'GET',
              data:'input_id='+input_id+'&amp;val='+value});
  </code></pre>
  
  <p>Below is code anyone can try who has access to PHP enabled server and firebug. Look at the firebug response for each request, you will see that <code>&lt;br /&gt;</code> are added to the $.get and not to $.ajax.</p>
  
  <p>ajaxtest.html</p>
  
  <pre><code>&lt;form method="GET" onsubmit="return false"&gt;
      &lt;textarea id="data" name="data"&gt;a
          b
          c&lt;/textarea&gt;
      &lt;input type="submit" value="Submit" id="submit"&gt;        
  &lt;/form&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $('#submit').click(function(){
     var data = $('#data').val();
  
     $.get("data.php", { data: data });
  
  
     $.ajax({
          url:"data.php",
          type:'GET',
          data:'data='+data});
  
  });   
  &lt;/script&gt;
  </code></pre>
  
  <p>data.php</p>
  
  <pre><code>&lt;?php  echo nl2br($_GET['data']); ?&gt;
  </code></pre>