Created
October 24, 2011 23:43
-
-
Save tonycosentini/1310759 to your computer and use it in GitHub Desktop.
Empty Last.fm Page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="form"> | |
<input type="text" id="search" action="#" name="search" placeholder="Enter an artist..."/> | |
</div> | |
<div id="loading" style="display: none;"> | |
<h1 id="loading">Loading.</h1> | |
</div> | |
<div id="content" style="display: none;"> | |
<img id="image"/> | |
<h1 id="name"></h1> | |
<p id="bio"></p> | |
<a href="#" id="new">New Search</a> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#search').keypress(function(e) { | |
if(e.which == 13) { | |
$("#form").fadeOut(function() { | |
$("#loading").fadeIn(); | |
}); | |
// The rest of the code will go here. | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Last.fm Search</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + $("#search").val() + "&api_key=b25b959554ed76058ac220b7b2e0a026&format=json&callback=?", function(json) { | |
// Handle the API response here... | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#name").html(json.artist.name); | |
$("#image").attr('src', json.artist.image[4]['#text']); | |
$("#bio").html(json.artist.bio.summary); | |
$("#loading").fadeOut(function() { | |
$("#content").fadeIn(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("a#new").click(function () { | |
$("#content").fadeOut(function() { | |
$("#form").fadeIn(); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment