I have a online photo gallery and when you hover over a image an edit button appears that opens up a jquery prompt box in which you enter the caption after this has been entered i have the following code

var caption=prompt("Please enter new caption"," ");
    if (caption!=null)
    {
    var link = "?id="+ $(this).parents('.thumbnail').attr('id') + "&c=" + caption;
    $.post("../photo_c.html"+link);
    //alert($(this).parents('.thumbnail').attr('id'));  

    $("#loaddiv").slideUp(300).delay(800).fadeIn('3000');
    }

This should refresh the div but it wont it flashes but the PHP caption that comes from the database wont change even tho the script at photo_c.html is changing it and working, i have been informed to change it to this

var caption = prompt("Please enter new caption", " ");
if (caption != null) {
    var link = "?id=" + $(this).parents('.thumbnail').attr('id') + "&c=" + caption;
    $.post("../photo_c.html" + link,function(){
        $("#loaddiv").html(caption).slideUp(300).delay(800).fadeIn('3000');
    });      
}

But that refreshes div but only shows the caption that was entered not the actual data that belongs in the div the content is

<ul class="thumbnails gallery" id="loaddiv">
<?php 
$get_all_pics = mysql_query("SELECT * FROM gallery_photos");
while ($photos = mysql_fetch_array($get_all_pics)) {
    echo 
 '<li id="'.$photos['photo_id'].'" class="thumbnail">
    <a data-rel="popover" data-content="'.$photos['photo_caption'].'" style="background:url(/images/'.$photos['photo_filename'].')" title="Caption" href="/images/'.$photos['photo_filename'].'"><img class="grayscale" src="/images/'.$photos['photo_filename'].'" alt="'.$photos['photo_caption'].'"></a>
  </li>';
}
?>
</ul>

as you can see i need to update the captions that show on the images by refreshing the div -

Any help would be greatly appricated

Used Ajax

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.