'I am Unable to display the graph on button click
There is this project where I have to display a dynamic graph which updates automatically without refreshing the page. I was able to do this and I am currently using the buttons so that the user can manually click whatever graph he wants to look.
The problem is once I click the second button a graph is displayed, if I again click the first button it's output is not displayed. I have attached the code for your reference.
As for the java script code I have used Canvas Js sample code.
Here is the code which I used to represent the graphs using buttons
<button id="refresh" type="button" onclick="start_p1();">Click for Process_1</button>
<div id="chartContainer1" class="w3-display-middle" style="height: 300px; width: 100%;"></div>
<button type="button" onclick="start_p2()">Click for Process_2</button>
<div id="chartContainer2" class="w3-display-middle" style="height: 300px; width: 100%;"></div>
<script type="text/javascript">
$("refresh").click(function(){
$("chartContainer1").load(" #chartContainer1");
});
</script>
I even looked about reloading the div tag but it doesn't help me as expected. I would appreciate the help. Thanks in advance..
Edit: I have included my output in the form of image so that you can understand clearly.
My output
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|