example.js 720B

1234567891011121314151617181920212223242526
  1. var stringStr;
  2. var Http = new XMLHttpRequest();
  3. var url='https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD';
  4. http.open('GET',url);
  5. var string=JSON.parse(Http.responseText);
  6. console.log(string );
  7. http.send();
  8. //
  9. // var getJSON = function(url, callback) {
  10. // var xhr = new XMLHttpRequest();
  11. // xhr.open('GET', url, true);
  12. // xhr.responseType = 'json';
  13. // var responseText=JSON.parse(xhr.response)
  14. // xhr.onload = function() {
  15. // var status = xhr.status;
  16. // if (status === 200) {
  17. // callback(null, xhr.response);
  18. // } else {
  19. // callback(status, xhr.response);
  20. // }
  21. // };
  22. // xhr.send();
  23. // console.log(responseText );
  24. // };