title: Passing a variable to an Ajax call
body: <p>I am using the code below to rotate and save an image stored on the server.</p>
  
  <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://beneposto.pl/jqueryrotate/js/jQueryRotateCompressed.js"&gt;&lt;/script&gt;
  
  &lt;img src="uploads/101822973264163759893-1428320267361.jpeg" id="img"/&gt;
  
  &lt;script&gt; 
  $(document).ready(function(){
  var value = 0
      $("#img").rotate({ 
         bind: 
           { 
              click: function(){
                  value +=90;
                  $(this).rotate({ animateTo:value})
              }
           } 
  
      });
  
  
      $(document).on('click', '#img', function() {
                  // alert("Hello");
  
                  var idno = "test";
                  $.ajax({
                           url: "saveimage.php",
                           dataType: "html",
                           type: 'POST',
                           data: "panelid="+idno, //variable with data
                           success: function(data){
                              // $(".test").html(data);
                                  // alert(data);
                           }
                  });
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>saveimage.php</p>
  
  <pre><code>&lt;?Php
  $degrees = -90;  //change this to be whatever degree of rotation you want
  
  header('Content-type: image/jpeg');
  
  $filename = 'uploads/101822973264163759893-1428320267361.jpeg';  //this is the original file
  
  $source = imagecreatefromjpeg($filename) or notfound();
  $rotate = imagerotate($source,$degrees,0);
  
  imagejpeg($rotate,$filename); //save the new image
  
  imagedestroy($source); //free up the memory
  imagedestroy($rotate);  //free up the memory
  
  ?&gt;
  </code></pre>
  
  <p>I found this code here - <a href="http://www.codehaven.co.uk/rotate-and-save-an-image-using-php/" rel="nofollow noreferrer">http://www.codehaven.co.uk/rotate-and-save-an-image-using-php/</a>.</p>
  
  <p>This all works fine but I am trying to pass a PHP variable which holds the image path and name to the ajax call and have no idea on how to do this.</p>
  
  <p>Can anyone help?</p>
  
  <p>thanks,</p>
  
  <p>John</p>