title: How to revert draggable element on failed ajax post request
body: <p>i have a element of images that i want to be able to be able to drag to a droppable zone, and fire a ajax post request but if it fails the draggable element should revert back to it's place.</p>
  
  <p>Also how do i find which was the droppable zone that the element was drop inside, i know how to find that item that was dropped but not the zone it was dropped in.</p>
  
  <p>However as i am new to jquery, i am having problems getting this to work. my code for now is as follows</p>
  
  <pre><code>$(function() {
      $(".drag").draggable( { revert:"invalid"} );
      $(".drop").droppable({
          accept: ".drag",
          drop: function( event, ui ) {
              var imageId = ui.draggable.attr("id");
              var targetLocation= 'something'; //no idea how to find zone dropped into
              var formdata={id:imageId};
  
         $.post( "&lt;?php echo base_url('home/test'); ?&gt;", { image_id: imageId })
        .done(function( data ) {
          var status = $.parseJSON(data);
          // console.log(status['status']);
          if (status['status']=='success') { 
              failure= false;
              $(ui.draggable).hide("slow");
           }
        },'json');          
  
          }
  
      });
    });
  </code></pre>