Ciao a tutti.
Premetto che non sono un esperto di JS.
Per un mio cliente devo esportare dei dati in formato JSON da un sito e leggerli con un script.
Il rete ho trovato il seguente esempio che mi permetterebbe di fare qualcosa di analogo:
Lato client:
codice HTML:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>Test</h2>
<script>
function getData() {
  var the_object ;
  var xhr = new XMLHttpRequest() ;
  var url = "http://www.miosito.com/test.js" ;
  xhr.open("GET", url, true) ;
  xhr.onreadystatechange = function () {
    if (xhr.readyState == 4) {
    console.log("State ready!") ;
    if (xhr.status == 200) {
      the_object = JSON.parse(xhr.responseText) ;
      msg  = the_object.items[0].value + "-" ;
      msg += the_object.items[0].order ;
      alert(msg) ;
    } else {
      alert("Si e' verificato un problema con l'URL.");
    }
    }
  } ;
  console.log("Sending request") ;
  xhr.send(null) ;
}
</script>
</body>
</html>
Lato server (cioè il file test.js, in formato json):
codice HTML:
{ "type": "Sample",
  "value": "List",
  "items": [
    {"value": "Uno", "order": "Primo"  },
    {"value": "Due", "order": "Secondo"},
    {"value": "Tre", "order": "Terzo"  }
  ] }
Ma a me non funziona. Praticamente a schermo non da errori ma non visualizza nulla.
Dove sbaglio ?

Grazie 1000