链接ajax加载php和刷新div

I have a system to upload images, but I would like to add the option to rotate the image using Ajax, the problem is that if the full page update variable session is lost, then only need to update the div where the image is located.

I can not use form because the link is in a form, so it has to be this way, if possible ...

This is what I'm trying:

index.php

<?php session_start(); ?>  
...  
<form>   

...

<div id="thumbs">
<?php
 if(isset($_SESSION['sess_img'])){
  echo '
   <a href="#" class="link" data-artid="'.$_SESSION['sess_img'].'">Rotate</a>
  ';
 }
?>
</div>

...

</form>

...

<script type="text/javascript">
$(function(){
    $('.link').click(function(){
        var elem = $(this);
        $.ajax({
            type: "GET",
            url: "rotate.php",
            data: "file="+elem.attr('data-artid'),
            success: function(result) {
             $("#thumbs").html(result);
            }
        });
        return false;
    });
});
</script>

rotate.php

<?php 
 session_start();
 $route = 'uploads/img/'; 
 $file = $_GET['file'];     
 rotateImage($route.$file, $route.$file, 90); 
?>

The idea:

  1. Click the link.

  2. Process rotate.php

  3. Update thumbs div

Issue:

This code does nothing, it does not fail, but not run the PHP.

I feel your rotate.php code is not right. Check out this example. Maybe it'll help you out : http://php.net/manual/en/function.imagerotate.php#refsect1-function.imagerotate-examples