title: Sending Multiple variables with Jquery ajax
body: <p><strong>General Overview</strong></p>
  
  <p>Hi all, I have 4 spans in which values are inputted dynamically but for the purpose of this question i put in some values. I want to get the value from the spans, send them using ajax to a php file. If they meet the criteria set in the php file then the alert some message. This is what i have so far..</p>
  
  <p><strong>The HTML</strong></p>
  
  <p>This basically contains the span and some numbers within the span, the button below has an onclick event to call a JavaScript function called check.</p>
  
  <pre><code> &lt;span id="first" name="first"&gt;40&lt;/span&gt;
        &lt;span id="second" name="second"&gt;50&lt;/span&gt;
        &lt;span id="third" name="third"&gt;30&lt;/span&gt;
        &lt;span id="fourth" name="fourth"&gt;40&lt;/span&gt;&lt;/center&gt;
        &lt;input type="button" id="button" name="button" onClick="check()"/&gt;
  </code></pre>
  
  <p><strong>The JavaSript</strong></p>
  
  <p>This basically stores the value of each span field in a specified variable then tries to send these variable using ajax, then it alerts a message in retrieving a success message and same for a failed message.</p>
  
  <pre><code> function check() {
        var    one = $('#first').val();
         var   two = $('#second').val();
         var  three = $('#third').val();
         var  four = $('#fourth').val();  
  
      $.post("test.php",{ data : "one"+"&amp;two"+"&amp;three"+"&amp;four" } ,function(data)
          {
  
           if (data=="yay") //for no input
           { alert("yay");
           }
           else 
           {
           alert("nay");
           }
  
           }
  
  
          } 
  </code></pre>
  
  <p><strong>The PHP</strong>
  These are the conditions the values in the span fields have to meet, the ajax function retrieves the success and failed messages from here.</p>
  
  <pre><code>  $one = $_POST["first"];
          $two = $_POST["second"];
           $three =$_POST["third"];
           $four = $_POST["fourth"];
           if($one &gt; 5)        {
  
           echo "yay";
                             }
       elseif($two &gt; 10 )        {
  
           echo "yay";  }
  
               elseif($three &gt; 15 )        {
  
           echo "yay";  }
  
               elseif($four &gt; 20 )        {
  
           echo "yay";  }
  
             else{
                 echo "nay";
             }
  </code></pre>
  
  <p><strong>The Problem</strong></p>
  
  <p>After a bit of debugging it doesn't seem that the php is getting any value which means the data hasn't been passed properly. I don't think that's the way to pass multiple items through ajax. Does anyone know how i can fix this?
  Many Thanks in adance..</p>