The value of the transfer function to return the function of the jQuery function

I am writing a script that loads various content based on previously clicked links. (For Android application). I'm having data transfer issues for my callback 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 force the identifier to contain a value on warning.

+3
source share
1 answer

Have you tried creating a local variable to avoid overwriting id with 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();
}
+2
source

Source: https://habr.com/ru/post/1749243/


All Articles