title: Get data in json using javascript and datatables
body: <p>I have a javascript as below, which can fetch the data from backed in json format. But How can i pass it to another function , i.e datatables to populate it</p>
  
  <pre><code>&lt;script&gt;
  var returndata;
  
  $.getJSON("/api/dashboard_data/", success);
  
  function success(data) {
      returndata = data;
      window.alert(returndata);
      return returndata;
      // do something with data, which is an object
  }
  
  $(document).ready(function() {
        $('#example').DataTable( {
          data: returndata,
          columns: [
              { title: "Action" },
              { title: "Input" },
              { title: "State" },
              { title: "Completed" },
             { title: "Project" },
          ]
      } );
  } );
   &lt;/script&gt;
  </code></pre>
  
  <p>In above code in window.alert(returndata), i get the json data which has been returned from backed.</p>
  
  <p>But the same variable "returndata" when i use it in function ready  it is empty. How can i get it in ready function.</p>