Created
September 2, 2010 02:37
-
-
Save benjamine/561750 to your computer and use it in GitHub Desktop.
Accessing scrumy.com REST API with jquery
This file contains 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
var scrumyname = $.trim($('#scrumyname')[0].value); | |
var usrpwd64 = base64.encode(scrumyname + ':' + $('#scrumypwd')[0].value); | |
var currenturl = 'http://scrumy.com/api/scrumies/' + scrumyname + '/sprints/current.json'; | |
alert('accessing ' + currenturl); | |
$.ajax({ | |
url: currenturl, | |
beforeSend: function(req) { | |
req.setRequestHeader("Origin", document.location.protocol + "//" + document.location.host); | |
req.setRequestHeader("Authorization", "Basic " + usrpwd64); | |
}, | |
success: function(data, textStatus, req) { | |
if (!data.sprint) { | |
alert('error loading current sprint'); | |
} else { | |
var sprint = data.sprint; | |
var list = '<ul>'; | |
if (!sprint.stories || sprint.stories.length == 0) { | |
list += '<li><i>no stories</i></li>'; | |
} else { | |
for (var i = 0; i < sprint.stories.length; i++) { | |
var story = sprint.stories[i].story; | |
list += '<li>' + story.title + '</li>'; | |
} | |
} | |
list += '</ul>'; | |
$('#sprintstoriestitle').show(); | |
$('#sprintstories').html(list); | |
} | |
}, | |
error: function(req, textStatus, error) { | |
alert('error: ' + textStatus + ' ' + error); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment