title: jQuery AJAX adds '%20' as space, normal javascript xmlhttp request doesn't
body: <p>I have this <code>jQuery AJAX</code> function which retrive data from a <code>CKEDITOR text_area</code> and send it through <code>AJAX</code> to the <code>.php</code> file:</p>
  
  <pre><code>function saveEmailData(){
      var text_body = encodeURIComponent(CKEDITOR.instances.text_body.getData());
  
      $.ajax({
          url: 'al_ajax.php',
          cache: false,
          data: {area: text_body, use: 'savemaildata'},
          type: 'POST',
          success: function(result){
                      alert(result);
                   },
          error: function(result){
                      alert('Error');
                  },
      });
  }
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>$area = $link-&gt;real_escape_string($_POST['area']);
  
  $insert_query = $link-&gt;query("INSERT INTO ALLARME_EMAIL_TEXT (area)
                                  VALUES ('$area')
                                ON DUPLICATE KEY UPDATE
                                  area = '$area'
                                ")
                                or die('Error.');
  
  if($insert_query){          
      echo 'OK!';
  }
  </code></pre>
  
  <p>The problem is that using <code>jQuery AJAX</code>, I'll have on the database <code>%20</code>, with the normal <code>javascript function</code>, this doesn't happen: I always use. Why?</p>
  
  <pre><code>function saveEmailData(){
      var text_body = encodeURIComponent(CKEDITOR.instances.text_body.getData());
  
      if(window.XMLHttpRequest) {
        xmlhttp=new XMLHttpRequest();     
      } else {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
  
      xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
          alert(xmlhttp.responseText);
        }
      }
  
  xmlhttp.open("POST","al_ajax.php",true);
  xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  xmlhttp.send("area="+text_body);
  }
  </code></pre>