I am trying to build a project-page setup that auto populates the project details in Github using Github API. I have put up my HTML and JavaScript files in the gh-pages branch. But the jQuery.get() is not getting me any data. I checked with Firebug and found that the request gets sent and that response code is 200 OK, but no data is shown as received. There is no issue with the API, commandline curl -i url response is as expected.
My HTML is:
<h3>Project</h3>
<div id="project" name="sample-project"></div>
<h3>Contributors</h3>
<p id="collab"></p>
And my Javascript code is:
$(document).ready(function(){
var project = $('#project').attr('name');
var baseurl = "https://api.github.com/";
var url = baseurl + "repos/thamizha/";
url += project;
url += "/collaborators";
$.get(url, function(data){
$('#collab').text(JSON.stringify(data));
});
});
Update: I tried this too. No alert even.
$.getJSON(url, function(data){
$('#collab').html(JSON.stringify(data));
alert('Success');
});
I have not tried this but you should be able to use
$.getJSON()to do cross-domain requests: http://api.jquery.com/jQuery.getJSON/ (check-out theJSONPsection)–UPDATE–
I ran a test and if you are trying to make a cross-domain request without forcing the use of JSONP then you will receive a
200 OKstatus message but no actual response. I also found this code for setting up an AJAX request in jQuery for JSONP:This is from: http://remysharp.com/2007/10/08/what-is-jsonp/