title: jQuery data in JavaScript works with id but not without id
body: <p>jQuery json data is easily fetched from PHP without any issue. if i want to display same data with  it is coming without any issue but js file is external file not embedded in html. so if i want to pass the value of jQuery var into JavaScript it is not working but it is working in same HTML file with id.</p>
  
  <p>here is my jQuery external file</p>
  
  <pre><code>$(document).ready(function() {
      (function() {
          $('#upload-form2').ajaxForm({
              dataType: 'json',
               success: function(data) {
                  var html = '';
                  var sthtml = '';
                  var ndhtml = '',
                      downlo;
                  for (var i = 0; i &lt; data.length; i++) {
                      z = i + 1;
                      downlo = data[i];
                      html += '&lt;tr id="' + i + '"&gt;&lt;td&gt;' + z + '&lt;/td&gt;&lt;/tr&gt;';
                      sthtml += '' + downlo.stchart + '';
                      ndhtml += '' + downlo.ndchart + '';
                  }
                  $('#down-btn').html(html);
                 $('#checkk').html(sthtml);
                $('#chek').html(ndhtml);
                  $('#saving-details').html(html);
                 }
          })
      })();
    });
  </code></pre>
  
  <p>if i am padding checkk and chek id to  data is correctly being displayed data is { x: 1, y: 59 },{ x: 2, y: 93 },{ x: 3, y: 477 },{ x: 4, y: 506 }
   but when i try to pass the same variable in datapoints of canvasjs nothing is coming. 
  i tried setting those sthtml and ndhtml as global variable by declaring before ready function.did not worked.
  tried ''+sthtml+'' in datapoints did not work. tried canvasjs tutorial but they are passing external json file but i want to pass jquery var data as all data are already fetched correctly in jquery.</p>
  
  <p>is there anyway i can add data to below datapoints other than i tried below. like  but canvasjs will not accept this div in datapoints so some other way required</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  window.onload = function() {
      var sthtml = [];
      var ndhtml = [];
      var chart = new CanvasJS.Chart("chartContainer", {
          axisY: {},
  
          data: [{
              dataPoints: [sthtml]
          }, {
              dataPoints: [ndhtml]
          }],
  
          legend: {
              cursor: "pointer",
              itemclick: function(e) {
                  chart.render();
              }
          }
      });
      chart.render();
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>it is not duplicate as the referred question did not identify the root cause even so its different</p>