title: Combine multiple AJAX calls to one with PHP
body: <p>I have a script that retrieves PHP variables using the $get() function but I have multiple requests for each variable. I want to do this because I want the calls to be individual and not waiting to load all variables.</p>
  
  <p>Here is my simple code:</p>
  
  <p>FUNCTIONS.PHP</p>
  
  <pre><code>$content1 = 'This is a good solution.';
  $content2 = 'This is another good solution.';
  
  if(preg_match('[good]', $content1)) { 
  
  $result1 = "&lt;p&gt;Great, we found something here.&lt;/p&gt;";
  
  }else{
  
  $result1 = "&lt;p&gt;Oops, nooooo.&lt;/p&gt;";
  }
  /////////////////////////////////
  
  if(preg_match('[another]', $content2)) { 
  
  $result2 = "&lt;p&gt;Great, we found something here.&lt;/p&gt;";
  
  }else{
  
  $result2 = "&lt;p&gt;Oops, nooo.&lt;/p&gt;";
  }
  
  $action = $_GET['action'];
  
  switch ($action) {
  case 'result1':
  echo $result1;
  break;
  case 'result2':
  echo $result2;
  break;
  default:
  echo 'Test';
  
  }
  </code></pre>
  
  <p>GET.PHP</p>
  
  <pre><code>&lt;script type='text/javascript'&gt;
  
  $.get('functions.php?action=result1', function(data) { 
  
  $('.result1').html(data);
  
  });
  
  
  $.get('functions.php?action=result2', function(data) { 
  
  $('.result2').html(data);
  
  });
  
  &lt;/script&gt;
  
  &lt;div class="result1"&gt;&lt;/div&gt;
  &lt;div class="result2"&gt;&lt;/div&gt;
  &lt;div class="result3"&gt;&lt;/div&gt;
  &lt;div class="result4"&gt;&lt;/div&gt;
  ........
  </code></pre>
  
  <p>So how can I "combine" all javascript calls to one (using parameters, I do not know) so will not be necesary to create a call for each variable.</p>
  
  <pre><code> &lt;script type='text/javascript'&gt;
  
  $.get('functions.php?action=resultvariable', function(data) { 
  
  $('.result_variable...').html(data);
  
  });
  
  &lt;/script&gt;
  </code></pre>