<div id="chartimgs" data-options="region:'south',border:false" style="height: 240px;overflow: hidden;"><img id="totalimgtotal" align="left" src="${pageContext.request.contextPath}/xsgl/salelistAction!saleTotalChart.html?order=total"/><img id="totalimgbuyPrice" align="center" src="${pageContext.request.contextPath}/xsgl/salelistAction!saleTotalChart.html?order=buyPrice"/><img id="totalimgprofit" align="right" src="${pageContext.request.contextPath}/xsgl/salelistAction!saleTotalChart.html?order=profit"/></div>
如上,这个div显示了jfreechart返回的三个图标,希望做到当搜索条件修改的时候重新加载图片,一开始使用: $("#totalimgtotal").attr("src","${pageContext.request.contextPath}/xsgl/salelistAction!saleTotalChart.html?order=total");
结果图片并没有刷新,因为后端方法没有执行。 后来从一个修改头像的页面重新加载想到可以用random,src与原来的src不一样了应该不会不加载了吧。
$("#totalimgtotal").attr("src","${pageContext.request.contextPath}/xsgl/salelistAction!saleTotalChart.html?order=total&groupby="+groupby+"&random="+Math.random());
$("#totalimgbuyPrice").attr("src","${pageContext.request.contextPath}/xsgl/salelistAction!saleTotalChart.html?order=buyPrice&groupby="+groupby+"&random="+Math.random());
$("#totalimgprofit").attr("src","${pageContext.request.contextPath}/xsgl/salelistAction!saleTotalChart.html?order=profit&groupby="+groupby+"&random="+Math.random());
果然,成功鸟。
本文探讨如何在前端开发中实现图表动态加载,并通过引入随机参数解决页面刷新问题,确保图表随搜索条件变化实时更新。
1万+

被折叠的 条评论
为什么被折叠?



