从JSON获取Gravatar Img

I'm trying to parse data that will display a users Gravatar image. The JSON is the following : http://api.bfhstats.com/api/playerInfo?plat=pc&name=stewartps&output=js On line 34 is 'uGava' which is their gravatar URL. It should be then http://gravatar.com / + uGava

At the moment I have a form which asks for the user to input a name and select a platform.

This is the code I have for that:

$("#playerstuff").submit(function() {
    $.ajax({
        type: "GET",

        url: 'http://api.bfhstats.com/api/playerInfo?plat=' + document.getElementById("platform").value +'&name=' + document.getElementById("playername").value,  
        //datatype : "json",

        success: function(data)
        {
            document.getElementById("playerrank").innerHTML = '<img src="http://gamingstats.ga/' +data["player"]["rank"].imgLarge + '" />';
                            $("#formpanel").hide();
                            $("#dataret").show();
                            $("#playerimg").show();
        }
    });
    return false;
});

I also just have a standard Image

<div class="user-img-div" id="playerimg" style="display: none;" >
<center><img src="img.png" class="img-circle"></center>

</div>

So my question is how will i use that standard Image to display the users Gravatar from the JSON data?

The data you get is plain JS, not JSON. Also, you don't need to use the bracket notation when the object properties don't have special characters in them. Change your AJAX call to the following:

$("#playerstuff").submit(function(e){
    e.preventDefault();

    $.ajax({
        type: "GET",
        url: 'http://api.bfhstats.com/api/playerInfo?plat=' + document.getElementById("platform").value +'&name=' + document.getElementById("playername").value,
        // script data type
        datatype: "script",
        success: function(){
            var data = window.pd;
            $("#playerrank").html('<img src="http://gamingstats.ga/' +data.player.rank.imgLarge+'"/>');
            $("#formpanel").hide();
            $("#dataret").show();
            // Use Gravatar as user image
            $("#playerimg").attr('src', 'http://gravatar.com/'+data.player.uGava).show();
        }
    });
});

Alternatively, since their API does support JSON, you can change the output GET parameter and use this instead:

$("#playerstuff").submit(function(e){
    e.preventDefault();

    $.ajax({
        type: "GET",
        url: 'http://api.bfhstats.com/api/playerInfo?output=json&plat=' + document.getElementById("platform").value +'&name=' + document.getElementById("playername").value,
        // script data type
        datatype: "json",
        success: function(data){
            $("#playerrank").html('<img src="http://gamingstats.ga/' +data.player.rank.imgLarge+'"/>');
            $("#formpanel").hide();
            $("#dataret").show();
            // Use Gravatar as user image
            $("#playerimg").attr('src', 'http://gravatar.com/'+data.player.uGava).show();
        }
    });
});