Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. {
  2. "list":[{"rank":"1","fb_id":"12345","score":"3000"},
  3. {"rank":"2","fb_id":"12345","score":"2000"},
  4. {"rank":"3","fb_id":"123456","score":"1000"},
  5. {"rank":"5","fb_id":"123456","score":"2500"}],
  6. "roundscores":[{"score1":"1000","pos1":"3","score2":"2500","pos2":"5"}]
  7. }
  8.  
  9. $.ajax({
  10. type: "POST",
  11. url: "ajaxClassifica2.jsp",
  12. data: "selectedLevel="+selectedLevel+"&fb_id="+123456,
  13. success: function(data) {
  14. alert(data);
  15. var jsonlist = data.list;
  16. var jsonround = data.roundscores;
  17. alert(jsonlist);
  18. alert(jsonround);
  19. var strBuild = "";
  20. $.each(jsonobj, function(index, names)
  21. {
  22. strBuild ="<ul class="livelli">"
  23. +" <div class="social"> "
  24. +" <a href="#"><img src="images/ico_fb.png"></a>"
  25. +" <a href="#"><img src="images/ico_tw.png"></a>"
  26. +" </div>"
  27. +" <li><strong>Round 1:</strong> " + names.roundscores.score1 + "</li>"
  28. +" <li><strong>Posizione:</strong> " + names.roundscores.pos1 + " </li>"
  29. +" </ul>"
  30. +" <ul class="livelli">"
  31. +" <div class="social"> "
  32. +" <a href="#"><img src="images/ico_fb.png"></a>"
  33. +" <a href="#"><img src="images/ico_tw.png"></a>"
  34. +" </div>"
  35. +" <li><strong>Round 2:</strong> " + names.roundscores.score2 + "</li>"
  36. +" <li><strong>Posizione:</strong> " + names.roundscores.pos2 + "</li>"
  37. +" </ul>";
  38.  
  39. });
  40. }
  41. });
  42.  
  43. var obj = JSON.parse('{"list":[...]}');
  44. obj.roundscores[0].score1 // 1000
  45.  
  46. var json = '{ "list":[{"rank":"1","fb_id":"12345","score":"3000"},{"rank":"2","fb_id":"12345","score":"2000"},{"rank":"3","fb_id":"123456","score":"1000"},{"rank":"5","fb_id":"123456","score":"2500"}], "roundscores":[{"score1":"1000","pos1":"3","score2":"2500","pos2":"5"}] }';
  47. var obj = JSON.parse(json);
  48. var score1 = obj.roundscores[0].score1);
  49.  
  50. var jData = JSON.parse(rawData);
  51. alert(jData.roundscores[0].score1);
  52.  
  53. var jsonText = '{"name":"Frodo","address":"Hobbiton, The Shire"}';
  54. var person = JSON.parse(jsonText);
  55.  
  56. alert(person.name);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement