Search code examples
jqueryjquery-post

jQuery refresh div after .post completed


Is it possible to refresh a div once a piece of script has run?

I am trying to do a manual ranking system where items are listed but when I change the number in an input the following runs

jQuery

$('input.ranking').keyup(function(e) {
        var thisClass = $(this).attr('class');
        var substr = thisClass.split('-');
        var pdID = substr[1];
        var pdRank = $(this).val();
        qString = 'pdID='+pdID+'&pdRank='+pdRank;
        if(typeof timeout != 'undefined') clearTimeout(timeout);
        timeout = setTimeout(function(){
            //console.log(qString);
            $.post('/assets/inc/set-rank.php', qString, function (data) {
                //console.log(data);
            }, "json");

        }, 1000);
    });

This does't refresh the list or the page. Could someone assist


Solution

  • Use this:

    $.post('/assets/inc/set-rank.php', function(data) {
      $('.yourDivClass').html(data);
    });