title: How to print JSON response in javascript
body: <p>I am able to make a Ajax request and getting response as well in form of JSON string, still alert box of JavaScript is not showing actual response text.
  I am new to ajax concept and dont know much. </p>
  
  <p>Ajax-Call:-</p>
  
  <pre><code>Action triggered on dropdown
  &lt;select name="state" onchange="getOptions(this.value)"&gt;
  
  Javascript Function called :-
  function getOptions(state){
    AJAX.onreadystatechange = handler;
    AJAX.open("GET", "getData?id="+state);
    AJAX.send();
  };
  </code></pre>
  
  <p>Response Firebug is showing</p>
  
  <p><img src="https://i.stack.imgur.com/M2AO9.png" alt="Response Content"></p>
  
  <p>This is my code to fetch response and print.</p>
  
  <pre><code>function handler() {
    if(AJAX.readyState == 4 &amp;&amp; AJAX.status == 200) {
      var json = eval('(' + AJAX.responseText +')');
      alert('Success. Result:' + json);
    }
    else if (AJAX.readyState == 4 &amp;&amp; AJAX.status != 200) {
        alert('Something went wrong...');
    }
  }
  </code></pre>
  
  <p>Every time its a success but i get output as 
  <img src="https://i.stack.imgur.com/aVIZt.png" alt="enter image description here"></p>