我正在尝试创建一个迷你图表,其中从数据库中提取交易金额。但我遇到的问题是我无法从数据库直接检索多个值到html页面。这是我上面的htm代码。
<script type="text/javascript">
window.onload = function staticFetch(){
var thisURL = window.location.href;
var thisSession = new Array();
thisSession = thisURL.split("?"); //This grabs all URL parameters
var session = thisSession[1];
thisSession = session.split("="); //This gets the session ID from URL
var session_id = thisSession[1];
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
result=xmlhttp.responseText;
thisSession = result.split("&");
document.getElementById("account_status").innerHTML=thisSession[0];
document.getElementById("total_amount").innerHTML=thisSession[1];
document.getElementById("total_transactions").innerHTML=thisSession[2];
document.getElementById("balance_funds").innerHTML=thisSession[3];
document.getElementById("avg_amount").innerHTML=thisSession[4];
}
}
xmlhttp.open("GET","dashboardStaticFetch.php?session_id="+session_id,true);
xmlhttp.send();
}
</script>
<div class="text-center padder m-b-n-sm m-t-sm">
<div class="sparkline" data-type="line" data-resize="true" data-height="65" data-width="100%" data-line-width="2" data-line-color="#fff" data-spot-color="#fff" data-fill-color="" data-highlight-line-color="#fff" data-spot-radius="3">0,0,0,0,0,0,0,0,0,0,0,0</div>
</div>
我正在使用JavaScript onload函数,该函数使用php脚本
从数据库中获取数据