nats0128
nats0128

Reputation: 509

jquery refresh div once

I am after refreshing a div only one after a function - i currently have

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');
    }

the code is making an edit button appear on hover over the image to which opens a prompt box the user then enters the new value and this get sent to a php file which updates the database but when the script is complete im left with the old caption until i refresh the page, i need to refresh the div after the $.post so it loads up with the value of the new caption

Upvotes: 0

Views: 317

Answers (1)

Adil Shaikh
Adil Shaikh

Reputation: 44740

use post callback -

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');
    });      
}

Upvotes: 1

Related Questions