I'm new to jQuery and was wondering how I'd access $hidden outside of this function: $(this).hide(500, function ()
HTML
<div class="fl person">
<input type="hidden" name="userSaved" value="1" />
<img src="..." class="circle-mask" />
</div>
<div class="fl person">
<input type="hidden" name="userSaved" value="2" />
<img src="..." class="circle-mask" />
</div>
jQuery
<script>
$("div.person img").click(function () {
$(this).hide(500, function () {
$(this).parent("div").empty();
$(".main_page").appendTo("div.main_page").addClass("fl person");
var saved_id_user_who_voted = $hidden = $(this).siblings('input');
});
/* attach a submit handler to the form */
var saved_id_user_who_voted_val = "<?php echo $_SESSION['id']; ?>";
/* stop form from submitting normally */
event.preventDefault();
/* Send the data using post and put the results in a div */
$.ajax({
url: "saveSavedUserToDatabase.php",
type: "post",
data: {saved_id_user_who_voted:saved_id_user_who_voted_val, saved_id_user_voted_on:saved_id_user_voted_on_val}
});
});
</script>
I'd like to be able to access saved_id_user_who_voted outside of the current function so that I can post it using .ajax - right now it's not in scope.
Any help is appreciated.