Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 18th, 2013  |  syntax: None  |  size: 0.94 KB  |  views: 23  |  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. document.write(fbResults.cats[0].title);
  2.        
  3. <!DOCTYPE HTML>
  4. <html>
  5. <head>
  6. <title></title>
  7. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  8.  
  9. <script>
  10.  
  11.     $(document).ready(function() {
  12.         $.getJSON('http://mydomain.com/api/get_cats', function(fbResults) {
  13.             document.write(fbResults.cats[0].title);
  14.         });
  15.     });
  16. </script>
  17.  
  18. </head>
  19. <body>
  20.  
  21. </body>
  22. </html>
  23.        
  24. {"cats":[
  25.  
  26. {"id":"1","title":"mytitle1","colour":"#EE297C"},
  27. {"id":"2","title":"mytitle2","colour":"#EE412F"},
  28. {"id":"3","title":"mytitle3","colour":"#F5821F"},
  29. {"id":"4","title":"mytitle4","colour":"#00AEEF"},
  30. {"id":"5","title":"mytitle5","colour":"#00B495"},
  31. {"id":"6","title":"mytitle6","colour":"#006476"}
  32.  
  33. ]}
  34.        
  35. $('body').append('<p>'+fbResults.cats[0].title+'</p>');
  36.        
  37. $.each(fbResults.cats,function(index,item){
  38.     document.write(item.title);      
  39.   });
  40.        
  41. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
clone this paste RAW Paste Data