jQuery AJAX - Do Stuff in Success or Complete callbacks?


Staff member
I have a quick question about jQuery's AJAX function.

The way I do my ajax calls I do something along the lines of:

    type: "GET",
    url: "/wordpress/wp-admin/admin-ajax.php",
    dataType: 'html',
    data: ({ action: 'loadHomePage'}),
    beforeSend: function() {
        document.getElementById('loading').style.visibility = 'visible';
    complete: function(){
        }, 100);
    success: function(data){
        data = $.trim(data);

The trouble is, in this particular instance, it's a full website inside a facebook iframe that uses ajax for the page navigation, when navigating between pages it seems to fade the content in multiple times so I was wondering what the best practise was here for the fade in part - should it go in the complete part?

I had the resizing stuff originally in complete but having moved it I think it's made a difference but not sure if it's a placebo effect....

If so, do I achieve it by doing the following:

complete: function(data){
    // fade in etc

and secondly, is it ok to do this if complete comes before success in the ordering of the source code or is the order important, e.g. success and <em>then</em> complete?