0

I can't understand the flow of $.get function

Code 1 the click function is working and html

$(document).ready(function(){
    value = "Sentence";

    $.get("php.php", function(data){

        }, "json").done(function(data){

        value = data;

        $('#print').html(value[0]);

        $('a').click(function(){      //working if inside the done function
            alert($(this).attr('value'));
        }); 
    });
});

Code 2 if i put the click function outside done

$(document).ready(function(){
    value = "Sentence";

    $.get("php.php", function(data){

    }, "json").done(function(data){

        value = data;

    });

    $('#print').html(value[0]);       //problem here

        $('a').click(function(){
            alert($(this).attr('value'));
        }); 
});

Please help me to explain this

0 Answers0