Triggered by a button
HTML <Script the src = "jquery.min.js"> </ Script> <div ID = QZS style = "width: 382px; height: 282px; position: Absolute; background-Color: # FF0000; left: 109px ; top: 133px; "> <a href="#" onClick=setInterval("shoppingcat()",1)> click I run js -jquery function </a> </ div> JS function shoppingcat () { the Document .getElementById ( "qzs"). style.display = "none" // not displayed //document.getElementById("qzs").style.display = "block" // display }
http://jquery.cuishifeng.cn/jQuery.Ajax.html
First, triggered by a button operation
document.getElementById ( "qzs") choose to change the subject by positioning the div id
Second, open the page directly to the database to run fetch data via ajax php contact also packaged into json format
json format {} [] array of objects
var myChart = echarts.init(document.getElementById('bar_week')); var arr1=[],arr2=[],arr3=[]; function arrTest(){ $.ajax({ type:"post", async:false, url:"data.php", data:{}, dataType:"json", success:function(result){ //{"daming":[53,54,53],"ming":[56,59,57],"jin":[62,114,93],"zuo":[58,113,90]} //[{"public_zao":53,"public_zhong":54,"public_wan":53}] if (result) { for (var i = 0; i < result.length; i++) { arr1.push(result[i].public_zao); arr2.push(result[i].public_zhong); arr3.push(result[i].public_wan); } } } }) return arr1,arr2,arr3; } arrTest(); var option = { tooltip: { show: true }, legend: { data:['早餐报餐'] }, xAxis : [ { of the type: 'category', // the Data: arr1// Size column itemStyle: {// display values above data: [ "big future", "Tomorrow", "Today", "Yesterday"] } ], YAXIS: [ { of the type: 'value' } ], Series: [ { "name": "Breakfast Daily meal", " type ":" bar ", // funnel bar bar chart " Data ": of arr1, // barWidth: 39, column size // label: { Show: to true,// turn on the display position: 'top', // displayed at the top Normal: { textStyle: {// value style Color: 'Black', the fontSize: 16 } } } } } ] }; // load data objects is echarts myChart.setOption (Option); //}