title: Trying to pass variable values from JavaScript to PHP using AJAX
body: <p>I want to pass some values from JavaScript to PHP using jQuery/AJAX. I have the following "simplified" code, not sure what is that I am doing wrong. There seems to be quite a few similar questions/answers in StackOverflow, but none of the them are really helping. </p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div&gt;
  &lt;a href="#" id="text-id"&gt;Send text&lt;/a&gt;
  &lt;textarea id="source1" name="source1" rows="5" cols="20"&gt;&lt;/textarea&gt;
  &lt;textarea id="source2" name="source2" rows="5" cols="20"&gt;&lt;/textarea&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JAVASCRIPT:</p>
  
  <pre><code>$("#text-id").click(function() {
  $.ajax({
  type: 'post',
  url: 'text.php',
  data: {source1: "some text", source2: "some text 2"}
  });
  });
  </code></pre>
  
  <p>PHP (text.php):</p>
  
  <pre><code>&lt;?php 
  
  $src1= $_POST['source1'];  
  $src2= $_POST['source2'];     
  
  echo $src1; 
  echo $src2;
  
  ?&gt;
  </code></pre>
  
  <p>The problem:  Nothing is happening...no errors..nothing. I don't see the values of 'source1' and 'source2' showing up in the PHP echo statements.</p>