title: Parsing URL jQuery AJAX form
body: <p>Basically i'm trying to send a video along with other info through jQuery to PHP to be written to a txt file to be read later.</p>
  
  <p>There is a way of inputting a video url into this. I've got everything working except one thing.</p>
  
  <p>If i put this through: <a href="http://www.youtube.com/watch?v=g1lBwbhlPtM" rel="nofollow">http://www.youtube.com/watch?v=g1lBwbhlPtM</a>
  it works fine.</p>
  
  <p>but this: <a href="http://www.youtube.com/watch?v=g1lBwbhlPtM&amp;feature=feedu" rel="nofollow">http://www.youtube.com/watch?v=g1lBwbhlPtM&amp;feature=feedu</a>
  doesn't.</p>
  
  <p>I've done some tests and it's because when i send the second url through &amp;feature=feedu gets read as a separate $_POST value.</p>
  
  <p>This is the problem:</p>
  
  <pre><code>    var dataString = 'title='+title+'&amp;content='+content+'&amp;date='+date+'&amp;Submit=YES'; 
  </code></pre>
  
  <p>because its reading like </p>
  
  <p><code>var dataString = 'title='+title+'&amp;content='+IMAGES, TEXT AND STUFF+'&amp;feature=feedu OTHER IMAGES AND STUFF&amp;date='+date+'&amp;Submit=YES';</code></p>
  
  <p>it's out of a textarea that could include images or text and stuff so im looking for something like htmlspecialchars() to sort out that &amp; before sending it through ajax</p>
  
  <p>Any ideas how to solve this?</p>
  
  <p>EDIT:
  Here's the full code that's the problem:</p>
  
  <pre><code>    var title = $('input#title').val(); 
      var content = $('textarea#content').val();
      var date = $('input#date').val();
      var dataString = 'title='+title+'&amp;content='+content+'&amp;date='+date+'&amp;Submit=YES'; 
      //alert (dataString);return false;
      $.ajax({
       type: "POST",
       url: "./inc/php/file.php",
       dataType: "json",
       data: dataString,
       success: function(data) {
          if(data.error == true){
               $('.errordiv').show().html(data.message);
          }else{
               $('.errordiv').show().html(data.message);
               $(':input','#addstuff')
                  .not(':button, :submit, :reset, :hidden')
                  .val('')
                  .removeAttr('checked')
                  .removeAttr('selected');
          }
         },
         error: function(data) {
          $('.errordiv').html(data.message+' --- SCRIPT ERROR');
         }
  
      })
      return false;
  </code></pre>
  
  <p>if content equals:</p>
  
  <pre><code>&amp;content= &lt;br&gt;Text 1&lt;br&gt; &lt;img&gt;http://someimage.com/image.jpg&lt;/img&gt; 
  &lt;br&gt; Text2&lt;br&gt; &lt;vid&gt;http://www.youtube.com/watch?v=isDIHIHI&amp;feature=feedu&lt;/vid&gt; 
  &lt;br&gt;Text 3&lt;br&gt;
  </code></pre>
  
  <p>the content variable gets put through the ajax call as:</p>
  
  <pre><code>&amp;content= &lt;br&gt;Text 1&lt;br&gt; &lt;img&gt;http://someimage.com/image.jpg&lt;/img&gt; 
  &lt;br&gt; Text2&lt;br&gt; &lt;vid&gt;http://www.youtube.com/watch?v=isDIHIHI
  </code></pre>
  
  <p>with an extra variable that is</p>
  
  <pre><code>&amp;feature=feedu&lt;/vid&gt; 
  &lt;br&gt;Text 3&lt;br&gt;
  </code></pre>
  
  <p>So how do u stop the ajax reading &amp;feature as a separate $_POST variable?</p>