Am having a issue with ajax form for some reason it dont always work post the correct data am having to click the image 3 or 4 times before it will load the portrait and gallery numbers.
can anyone help me out ?
** Form.php**
<script>
$(document).ready(function() {
$('.ajaxform').click(function()
{
var avatar = $(this).data("portrait");
var avatardir = $(this).data("gallery");
$.post('update.php', {avatar : avatar, avatardir : avatardir}, function(data, status)
{
$("#info").html(data);
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
<div id="info">
<input name="updateMyPortrait" type="hidden" id="updateMyPortrait" value="1" />
<input name="avatardir" type="hidden" id="avatardir" value="<?php echo $_POST['avatardir']; ?>" />
<input name="avatar" type="hidden" id="avatar" value="<?php echo $_POST['avatar']; ?>" />
</div>
** input image for clicking on:**
<td><div><input class=\"ajaxform\" data-portrait=\"#{$str3}\" data-gallery=\"#{$avatarimg}\" type=\"image\" src=\"{$files[$pos]}\" width=\"88\" height=\"88\" border=\"1\"></div></td>
** update.php:**
<input name="avatardir" type="hidden" id="avatardir" value="<?php echo $_POST['avatardir']; ?>" />
<input name="avatar" type="hidden" id="avatar" value="<?php echo $_POST['avatar']; ?>" />
Thanks.