title: Ajax function not sending data onclick
body: <p>PROBLEM SOLVED!!!</p>
  
  <p>HOW?</p>
  
  <p>First of all the mistake is this one:</p>
  
  <p>data: 'rate' + $('rate').val(),</p>
  
  <p>what needs to get changed as you all told me right to:</p>
  
  <p>data: 'rate='+rate, or data: {rate: rate},</p>
  
  <p>but there is also another problem with my server settings as well which needs (I dont know the reason) an absolt URL to the php file instead a relative. </p>
  
  <p>THANK YOU ALL FOR YOUR TIME AND YOUR KIND HELP!</p>
  
  <hr>
  
  <p>I am having some trouble with an onclick element for a rating script. When a user clicks on one of those fields, the value should be send via an ajax post method. </p>
  
  <pre><code>&lt;li id="rating-boxes-rate" onclick="rateFunction(1)"&gt;&lt;/li&gt;
  &lt;li id="rating-boxes-rate" onclick="rateFunction(2)"&gt;&lt;/li&gt;
  &lt;li id="rating-boxes-rate" onclick="rateFunction(3)"&gt;&lt;/li&gt;
  &lt;li id="rating-boxes-rate" onclick="rateFunction(4)"&gt;&lt;/li&gt;
  &lt;li id="rating-boxes-rate" onclick="rateFunction(5)"&gt;&lt;/li&gt;
  </code></pre>
  
  <p>The javsscript code:</p>
  
  <pre><code>function rateFunction(rate){
       $.ajax({
           url: '../rate.php',                    //rate.php location in parent folder
           type: 'POST',
           data: 'rate' + $('rate').val(),
           success: function(html){
                       alert('Rating: ' + rate);          //just to check, will be deleted later
                       $('#message_success').html(html); //message div id located in my html to show the outcome
           }
       });
       return false;
  }
  </code></pre>
  
  <p>At this point the alert gets shown correctly but unfortunately the data is not getting send to the rate.php which at this point is a simple echo statement for testing:</p>
  
  <pre><code>$rate = $_POST['rate'];
  echo $rate;
  </code></pre>
  
  <p>Does anyone see where exactely my code is wrong? Thank you in advance.</p>