views:

32

answers:

1

I'm writing a script that loads different content based on the previously clicked links. (For an Android app). I'm having problems getting data to pass to my call back function.

function load_current_div(id, refer){
    $('#current-div').hide(function(){
        $('#current-div').html('');
        $('#current-div').load('content/'+id+'.html', function(){
            alert(id);
        });
    });
    $('#current-div').show();
}

I cannot get the id to contain a value when alerted.

+1  A: 

Have you tried creating a local variable to avoid the id being overwritten by something else ?

function load_current_div(id, refer){
    $('#current-div').hide(function(){
        var local_id = id;
        $('#current-div').html('');
        $('#current-div').load('content/'+local_id+'.html', function(){
            alert(local_id);
        });
    });
    $('#current-div').show();
}
Gaby
I tried that. But no I am unsure if the call back is actually working. The pages load fine and then nothing else happens.
Tim
@Tim, use firebug to see what the ajax call returns .. (if it does..)
Gaby