Home forums Using CanvasJS Collection data with Ajax Reply To: Collection data with Ajax


Vishwas R

Generally JavaScript code will function in the head before code in the body. The head section is usually used to contain information about the page that you don’t necessarily see like the meta keywords meta description or title of a page.

Here in your case, Buttons with id ‘chart1’ and ‘chart2’ are created after script is run, but where it fails to fetch buttons with those ids. You can move script tag to body so that it works fine. Here is your working code.

Refer these links for more info on placement of JavaScript code.

  • This reply was modified 5 months ago by  Vishwas R.