qq_35649402
你们让我起个名啊
2017-04-18 07:59

jsp页面怎么传值给js?

25
  • json
  • ajax

请问该怎么把ID传到json中?
jsp部分代码

 <c:forEach items="${page.list}" var="tblTemperatureAxis">
            <tr>
                <td><a href="${ctx}/temperatureaxis/tblTemperatureAxis/form?id=${tblTemperatureAxis.id}">
                    ${tblTemperatureAxis.tagId}
                </a></td>
                <td>
                    <fmt:formatDate value="${tblTemperatureAxis.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
                </td>
                <td>
                    ${tblTemperatureAxis.temperature}
                </td>
                <td>
                    ${tblTemperatureAxis.remarks}
                </td>

ajax

 var id=[];
    var temperature=[];
    var addTime=[];
    $.ajax({
        type:"post",
        async:true,//异步请求
        url:"${ctx}/temperatureaxis/tblTemperatureAxis/axisTem"
        data:{},
        dataType:"json",
        success:function(result){
            if(result!=null&&result.length>0){
                for(var i=0;i<result.length;i++){
                    temperature.push(result[i].temperature);
                    addTime.push(result[i].addTime);
                }
                myChart.setOption({
                    xAxis:[{
                        data:addTime
                    }],

                        series:[{
                        data:temperature
                        }]


                })
            }
        }
    });
    myChart.setOption(option);
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

7条回答