Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. var content = new Array();
  2. $.getJSON("http://riverdalecornercafe.com/wp/category/isd/feed/json", function(data) {
  3. $.each(data, function(i, item) {
  4. content.push(item.content);
  5. });
  6. console.log(content[0]);
  7. });
  8.  
  9. <div class="main">
  10. <div class="title"></div>
  11. <div class="content"></div>
  12. </div>
  13.  
  14. $.ajax({
  15. type: "POST",
  16. contentType: "application/json; charset=utf-8",
  17. dataType: "json",
  18. url: "http://riverdalecornercafe.com/wp/category/isd/feed/json",
  19. success: function(jsonArray) {
  20. for (var i = 0; i < jsonArray.length; i++)
  21. {
  22. $('.content').append(/*the format you want to add in html */ json value : 'jsonArray[i].name)
  23. }
  24.  
  25.  
  26. error: function()
  27. {
  28. you can handle your error
  29. }
  30.  
  31. $.getJSON("http://riverdalecornercafe.com/wp/category/isd/feed/json", function(data) {
  32. var myJson = data;
  33. var lastItem = myJson.length;
  34. for (var i = 0; i < lastItem; i++){
  35. $('.content').append(myJson[i].title);
  36. }
  37. });
  38.  
  39. <script type="text/javascript" text="javascript">
  40. $.getJSON("http://riverdalecornercafe.com/wp/category/isd/feed/json", function (data) {
  41. var myJson = data;
  42. var lastItem = myJson.length;
  43. for (var i = 0; i < lastItem; i++) {
  44. $('.innerCarousel').css('width', (lastItem * 500) + 'px');
  45. $('.innerCarousel').html("<div style=float:left;width:500px;><img src='" + myJson[i].imagePath + "' /></div>");
  46. }
  47. });
  48. $('.next').on('click', function () {
  49. $('.innerCarousel').animate({ left: ($(this).css('left') - 500) + "px" },"medium");
  50. });
  51. $('.prev').on('click', function () {
  52. $('.innerCarousel').animate({ left: ($(this).css('left') + 500) + "px" }, "medium");
  53. });
  54. </script>
  55.  
  56.  
  57. <div style="width:500px;height:300px;overflow:hidden;position:relative;">
  58. <div class="innerCarousel" style="position:absolute;left:0px;"></div>
  59. <div class="next"></div>
  60. <div class="prev"></div>
  61. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement