-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajap.js
More file actions
45 lines (26 loc) · 962 Bytes
/
ajap.js
File metadata and controls
45 lines (26 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* Created by AaronG on 5/10/2015.
*/
$(document).ready(function(){
$("#go").click(function(){ getInfo(); });
});
function getInfo(){
var url = "http://teamtreehouse.com/"+ encodeURIComponent($('#name').val())+".json";
console.log(url);
$.ajax({
url: url,
context: document.body,
})
.done(function(data){
var userName= data.name;
var totalPoints=data.points.total;
var image = new Image;
image.src = data.gravatar_url;
var totalBadges=data.badges.length;
var img = $('<img src="' + image.src + '" "height=200 width=200" />');
$("#userInfo").html("<strong> Name: </strong>"+userName+"</br><strong> Total Points: </strong>"+totalPoints+"</br> <strong> Total Badges: </strong>"+totalBadges+"</br>" );
$("#img").append(img);
console.log(data);
console.log(image);
});
}