Guest User

Untitled

a guest
Jun 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. {
  2. "names" : {/*stuff needed for names goes in here*/},
  3. "dates" : {/*stuff needed for dates goes in here*/},
  4. "fuzzyThings" : {/*all fuzzy things goes in here*/}
  5. }
  6.  
  7. function handler(retText) {
  8. var returnedObject = eval(retText);
  9.  
  10. doStuffWithNames(returnedObject.names);
  11. doStuffWithDates(returnedObject.dates);
  12. playWithFuzzyThings(returnedObject.fuzzyThings);
  13. }
  14.  
  15. <?php
  16. echo '{';
  17. echo '"names":{';
  18. include 'names.php';
  19. echo '},';
  20.  
  21. echo '"dates":{';
  22. include 'dates.php';
  23. echo '},';
  24.  
  25. echo '"fuzzyThings":{';
  26. include 'fuzzyThings.php';
  27. echo '}';
  28. echo '}';
  29. ?>
  30.  
  31. "user" : [ {
  32. "name" : "Harry",
  33. "hobby" : "Skating"
  34. }, {
  35. "name" : "Dave",
  36. "hobby" : "Scuba Diving"
  37. } ],
  38. "news" : [ {
  39. "date" : "3/13/05",
  40. "title" : "Blah",
  41. "postedby" : "Mike",
  42. } ]
  43.  
  44. var data = eval('('+ xhr.responseText +')'); // Ajax response
  45. var user = data.user[0].name; // Harry
  46. var user2 = data.user[1].name; // Dave
  47. var title = data.news[0].title;
Add Comment
Please, Sign In to add comment