Ajax -- re-load div on success.

Posted by RPM on Stack Overflow See other posts from Stack Overflow or by RPM
Published on 2011-06-28T12:46:32Z Indexed on 2011/06/28 16:22 UTC
Read the original article Hit count: 330

Filed under:
|
|

I am trying to accomplish a "re-load." More specifically, I need to be able to refresh a portion of my page as a result of another successful ajax call.

Moreover, I load my portion of the page via ajax which obtains it's content from an ajax post. The result is my content being displayed inside my portion precisely.

I need this portion of the page refreshed after a successful ajax post.

Here is some of the code:

/* Ajax-- this part is loaded automatically, and I need it reloaded upon 
   success of another ajax post. This data comes from the outcome 
   of my other ajax function. */ 


$('#newCo').load('click', function() {


        $.ajax({
            url: 'index.php?dkd432k=uBus/310/Indeed',
            dataType: 'json',
            success: function(json) {
                if (json['newCompare']) {
                    $('#newCo .newResults').html(json['newCompare']);
                     }
                 }
            });

        });

The next portion of code is responsible for posting the data of which I obtain in this above ajax function.

function ZgHiapud (ofWhich) { 
$.ajax({
    url: 'index.php?dkd432k=uBus/310/update',
    type: 'post',
    data: 'product_id=' + product_id,
    dataType: 'json',
    success: function(json) {
        $('.success, .warning, .attention, .information').remove();

        if (json['success']) {


            $('.attention').fadeIn('slow');

            $('#compare_total').html(json['total']);



            $('html, body').animate({ scrollTop: 0 }, 'slow'); 


        }   
    }
});
}

In the end, I need to obtain the data that I send to the server immediately upon success of the second ajax call. This data that is sent via the second ajax call needs to fire the first ajax call upon success.

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about JSON