title: How do you get Javascript to see tinyint(1) data pulled via AJAX request as boolean?
body: <p>I am having a problem and after hours of searching for answers and playing around with it I cannot get it to work.</p>
  
  <p>My problem. I have a MYSQL database. When I pull my "boolean" data from the database via PHP it is just fine. PHP interprets the "strings" of 1's and 0's as True and False. However, when I retrieve this data to populate a form with Ajax I run into a problem.</p>
  
  <p>The string comes out as: {"id":"478","name":"aaaa","manager":"385","usertype":"0","typeone":"0","typetwo":"1","typethree":"1"}</p>
  
  <p>That is just fine. Until I try to populate a form with the data using:</p>
  
  <pre><code>$.each(data, function (name, val) {
  var $el = $('[id="e' + name + '"]'),
      type = $el.attr('type');
  
  switch (type) {
      case 'checkbox':
          $el.filter('[value="' + Boolean(val) + '"]').attr('checked', 'checked');
          break;
      case 'radio':
          $el.filter('[value="' + val + '"]').attr('checked', 'checked');
          break;
      default:
          $el.val(val);
  }
  });
  </code></pre>
  
  <p>On this <a href="http://jsfiddle.net/z66XF/11/" rel="nofollow">http://jsfiddle.net/z66XF/11/</a> you can see that data used to check off the check boxes doesn't work when it comes from my database with the "boolean" values given as strings.</p>
  
  <p>"0" ends up being evaluated as true.</p>
  
  <p>Is there any way to convert this or have javascript see it as boolean?</p>