php - Loading data into the current div -


i have 2 divs, , when 1 clicked empties div. want able load data div once it's been emptied. i've got loads in both, want load data div that's been emptied.

html (i have 2 of these)

<div class="fl person">     <div class="maintain_size">         <input type="hidden" name="usersaved" value="<?php echo $user_one['id']; ?>" />             <img src="<?php echo "http://graph.facebook.com/".$user_one['id']."/picture?type=large"; ?>" class="circle-mask"  />             <img class="hoverimage" src="images/fire_extinguisher.png" />             <div class="meta_data">                 <h2><?php echo $user_one['name']; ?></h2>             </div>     </div> </div> 

javascript

<script> $("div.person img").click(function () {         $(this).parent("div").fadeout(1000, function () {         var saved_id_user_who_voted_val = "<?php echo $_session['id']; ?>";         var saved_id_user_voted_on_val = $(this).parent('div').find('input:hidden');         var saved_id_user_voted_on_val = saved_id_user_voted_on_val.val();          $(this).parent("div").empty();          // load in new data         var current_div = $(this).parent("div");         $.get('loadnewuser.php', function(data) {           current_div.html(data);         });     }); }); </script> 

the data seems come through fine if select div that's not current one, or use alert see if data there--which is, if try load data current div doesn't work. ideas? thanks.

the code think wrong:

$.get('loadnewuser.php', function(data) {       current_div.html(data); }); 

edit: div i'm trying data is: div.person - although, there 2 of these.

once empty div 'this' no longer there. try declaring var current_div before empty.

var current_div = $(this).parent("div"); current_div.empty(); $.get('loadnewuser.php', function(data) {       current_div.html(data); }); 

see fiddle


Comments