我正在使用jQuery .load
通过Ajax加载视图。出于某种原因,它不断向服务器发出请求。
$("#service_level").load("/charts/service_level", function() {
return false;
});
这是正在加载的视图
<%= content_tag :div, "", id: "shipments-by-service-type", data: {shipments: @charts[:service_analysis][:spend_data]} %>
<script type="text/javascript">
var dataArr, obj, prop;
dataArr = [];
obj = $("#shipments-by-service-type").data("shipments");
for (prop in obj) {
dataArr.push({
label: prop,
value: obj[prop]
});
}
Morris.Donut({
element: "shipments-by-service-type",
data: dataArr,
preUnits: '$'
});
</script>