Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.01 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. jquery ajax json
  2. <script type="text/javascript">
  3. $(document).ready(function() {
  4.  
  5. $.ajax({
  6.     url: "https://api.github.com/repos/VonC/gitolite/git/refs/tags",
  7.     dataType: "jsonp", // I'm under the impression i should use jsonp, since this is a cross domain call
  8.     success: function (returndata)
  9.     {
  10.         $('.result').html(returndata);
  11.         alert('Load was performed.');
  12.       }  
  13.     });
  14.  });
  15. </script>
  16.        
  17. [
  18. {
  19. "object": {
  20.   "type": "commit",
  21.   "sha": "9accde83842523e18de320fc2f0a8efeaebef27b",
  22.   "url": "https://api.github.com/repos/jeffreycwitt/jeffswebpage/git/commits/9accde83842523e18de320fc2f0a8efeaebef27b"
  23.  },
  24. "url": "https://api.github.com/repos/jeffreycwitt/jeffswebpage/git/refs/heads/master",
  25. "ref": "refs/heads/master"
  26.  }
  27. ]
  28.        
  29. $.ajax({
  30.     url: "https://api.github.com/repos/VonC/gitolite/git/refs/tags",
  31.     dataType: "json",
  32.     success: function (returndata)
  33.     {
  34.         $("#result").html(returndata[0]["object"]["sha"]);
  35.         alert('Load was performed.');
  36.     }  
  37. });
  38.        
  39. returndata[0].object.sha