title: How to assign AJAX JSON response to jquery variable?
body: <p>When some one clicks the category button an AJAX request send to <code>category.php</code> in this php file i am encoding a JSON response.</p>
  
  <p><strong>Jquery Onclick Function</strong></p>
  
  <pre><code>$('#Category').change(function(){            
      var j;
    $.ajax({
     url:'categories.php',
     success: function(results){
        var obj = JSON.parse(status);
         alert(obj);
     }                
    });            
  });
  </code></pre>
  
  <p><strong>category.php File</strong></p>
  
  <pre><code>&lt;option value="" selected=""&gt;Select Sub Category&lt;/option&gt;
  &lt;option value="Cars"&gt;Cars&lt;/option&gt;
  &lt;option value="Motorbikes &amp; Scooters"&gt;Motorbikes &amp; Scooters&lt;/option&gt;
  
      $status = array('type' =&gt; 'yes');
      echo json_encode($status);
  </code></pre>
  
  <p>Now how to assign <strong>yes</strong> to a JQuery variable on AJAX success? i tried some codes (in Above JQuery codes) but that didn't work please suggest me a solution.</p>