exp.html 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type=" text/javascript">
  5. var httpClient=function(){
  6. var movies;
  7. //this.get=function(eUrl,eCallback);{
  8. var onHttpRequest=new XMLHttpRequest({mozSystem: true});
  9. onHttpRequest.onreadystatechange=function(){
  10. if(onHttpRequest.readyState==4 &&onHttpRequest.status ==200)
  11. {
  12. movies=JSON.parse(onHttpRequest.responseText);
  13. for(var i=0;i<movies.data.length;i++){
  14. var movie=movies.data[i];
  15. if(movie[10]=="Golden Gate Bridge"){
  16. // document.getElementById('result').innerHTML +=(movie[8]+ " "+movie[9]+" "+movie[12]) + "<br>";
  17. document.getElementById('result').innerHTML +=(movie[8] + " " + movie[9] + " " + movie[12]) + "<br>";
  18. }
  19. }
  20. }
  21. // onHttpRequest.open('GET',eUrl,true);
  22. // onHttpRequest.send();
  23. }
  24. var theurl='https://data.sfgov.org/api/views/yitu-d5am/rows.json?accessType=DOWNLOAD';
  25. // var client=new HttpClient();
  26. // client.get(theurl,function(response) ){
  27. // var response1=JSON.parse(response);
  28. // });
  29. onHttpRequest.open("GET",theurl,true);
  30. onHttpRequest.setRequestHeader("Content-Type","text/plain");
  31. onHttpRequest.send();
  32. return movies;
  33. }
  34. httpClient();
  35. </script>
  36. </head>
  37. <body>
  38. </body>
  39. </html>