title: Javascript fails to fetch Json data from url
body: <p>I am trying to fetch json data from my server using Javascript, and I followed the solution provided <a href="https://stackoverflow.com/a/24587512/2867094">here</a>. But It doesn't work for me. And I found out that xhr.onload = function() not run in my case. How to figure it out?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
    &lt;div id="result" style="color:red"&gt;&lt;/div&gt;
     &lt;script&gt;
         var getJSON = function(url) {
         return new Promise(function(resolve, reject) {
         var xhr = new XMLHttpRequest();
         xhr.open('get', url, true);
         xhr.responseType = 'json';
         xhr.onload = function() {
         var status = xhr.status;
        if (status == 200) {
           resolve(xhr.response);
         } else {
           reject(status);
         }
      };
         xhr.send();
       });
         };
  
    getJSON('http://qlin.parseapp.com/version2/myres.txt').then(function(data) {
  alert('Your Json result is:  ' + data.result); //you can comment this, i used it to debug
  
  result.innerText = data.result; //display the result in an HTML element
         }, function(status) { //error detection....
           alert('Something went wrong.');
         });
         &lt;/script&gt;
         &lt;/body&gt;
         &lt;/html&gt;
  </code></pre>