日期:2014-05-16  浏览次数:20340 次

JSON --常用--

?

JS:

$.ajax({
	url : url,
	data:{
		depCity:$('#depCity').val(),
		bookingType:$('#bookingType').val()
		},
	cache : false, 
	async : false,
	type : "POST",
	complete: function(jqXHR, textStatus){
		if(jqXHR.status==200){
			result = parseObj(jqXHR.responseText)
			var data = result.json;
			var xml = result.xml;
			grid.ligerGrid({
				height:'300px',
				columns:columns_main,
				data:data,
				pageSize:10,
				rownumbers:true
			});
			$('#text').val(xml);
			setChart();
		}else{
			alert('查询失败,请与管理员联系');
		}
	}
});

?JSP:

<div style="display:none"><input id="text" type="text" value="<s:property value="xml"/>"></div>

?

JS:

var xml = document.getElementById('text').value;
var chart2 = new FusionCharts("<%=request.getContextPath() %>/FusionCharts/MSLine.swf", "chart2Id", width, "350");
		chart2.setDataXML(xml);

?

JAVA:

data = "{\"json\":"+json+",\"xml\":\""+xml+"\"}";
JsonUtil.toJSONOut(data);

?

================================================================================

JS:

$.ajax({
	url : url,
	data:{
		depCity:$('#depCity').val(),
		flightDate:$('#flightDate').val()
		},
	cache : false, 
	async : false,
	type : "POST",
	complete: function(jqXHR, textStatus){
		if(jqXHR.status==200){
			result = parseObj(jqXHR.responseText)
			var data = result.json;
			//var chartdata = '[[1, -12.70], [2, -12.00], [3, 1.00], [4, 5.00], [5, 6.00]]';
			var xml = result.xml;
			grid.ligerGrid({
				height:'300px',
				columns:columns_main,
				data:data,
				pageSize:10,
				rownumbers:true
			});
			$('#text').val(xml);
			setChart();
		}
	}
});

?

JSP:

<div style="display:none"><input id="text" type="text" value="<s:property value="xml"/>"></div>

?

JS:

var xml = document.getElementById('text').value;
chart2.setDataXML(xml);

?

JS:

chart.series[0].setData(data);

?

JS:

function setChart(){
		
		var chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'scatter',
                zoomType: 'xy'
            },
            title: {
                text: '渠道价差'
            },
            subtitle: {
                text: 'For the year 2013'
            },
            xAxis: {
            	allowDecimals:false,
                title: {
                    enabled: true,
                    text: '排名'
                },
                startOnTick: true,
                endOnTick: true,
                showLastLabel: true
            },
            yAxis: {
                title: {
                    text: '价差比例'
                }
            },
            series: [{
                name: '渠道差价',
                color: '#00FF',
                data: [[1, -12.70], [2, -12.00], [3, 1.00], [4, 5.00], [5, 6.00]]
    
            }]
        });
chart.series[0].setData(data); 
 	}

?