ajax利用json进行服务器与客户端的通信
2015-05-04 14:26
393 查看
1.JQuery中$.ajax()方法参数详解
http://blog.sina.com.cn/s/blog_4f925fc30100la36.html
2.服务器端获取String que=request.getParameter("que");
3.客户端请求完整代码(highcharts)。
View Code
http://blog.sina.com.cn/s/blog_4f925fc30100la36.html
2.服务器端获取String que=request.getParameter("que");
3.客户端请求完整代码(highcharts)。
<!DOCTYPE html> <html> <head> <title>MyHtml.html</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="keywords" content="keyword1,keyword2,keyword3"> <meta name="description" content="this is my page"> <meta name="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head> <body> <!-- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script> <script type="text/javascript" src="../js/highcharts.js"></script>--> <script src="http://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js"></script> <script src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script> <script type="text/javascript"> $(function() { //$("input[type=button]").bind("click", showChart); //alert('error!'); $('#show-button').on('click', function(e) { showChart(); }); $('#clear-button').on('click', function(e) { clearPlot(); }); }); var chart; function clearPlot() { //console.log("clear plot data!!!"); var series = chart.series; while (series.length > 0) { series[0].remove(false); } chart.redraw(); }; function showChart() { $.ajax({ url : "servlet/Charts", type : "POST", dataType : "json", data : { "que" : $("#inputque").val() }, success : function(data) { var json = eval(data); if (json != "" && json != null) { chart = new Highcharts.Chart({ chart : { renderTo : 'container', type : 'line' }, title : { text : '话题趋势分析' }, subtitle : { text : '' }, xAxis : { categories : json.categories }, yAxis : { title : { text : '百分比 (%)' }, min : 0 }, plotOptions : { line : { dataLabels : { enabled : true }, enableMouseTracking : true } }, tooltip : { formatter : function() { return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y + ' 次'; } }, series : json.series }); chart.settitle(null,null,true); } }, error : function() { alert('error!'); } }); } </script> <div style="margin:auto;text-align:center;"> <div style="padding:10px;"> <input type="text" name="que" id="inputque"> <input type="button" id="show-button" value=" Test Highcharts " /> <input type="button" id="clear-button" value="clean" /> </div> <div id="container" style="height:480px;width:980px;background-color:#efefef;"></div> </div> </body> </html>
View Code
相关文章推荐
- 客户端和应用服务器之间利用HttpClient和Servlet交互JSON对象进行通信
- Struts2服务器和Android客户端利用JSON进行数据的传递
- 【Linux网络编程实例】实例二:利用TCP协议进行客户端与服务器通信
- 一个完整的通过encoding/json信息传递格式,采用http.POST利用进行与服务器通信,并对返回结果进行解析处理的典型案例
- 利用C#进行socket编程(模拟服务器和客户端通信)
- android中利用Socket实现手机客户端与PC端进行通信
- 手机客户端和服务器通信时如何安全高效的进行身份验证
- 基于 Ajax 的 web 应用程序中各种客户端-服务器通信机制
- 解如何利用 XML 和 JavaScript Object Notation 在 Ajax 客户端和 Java 服务器之间传输数据。
- Linux C利用Socket套接字进行服务器与多个客户端进行通讯
- C#利用TcpListener和TcpClient类实现服务器和客户端的通信
- Ajax---通过JSON与服务器通信(发送请求和处理响应)
- 利用sockets实现服务器客户端简单通信
- 关于安卓手机做客户端pc做服务器进行Socket通信出现问题的解决案方
- Android入门:通过JSON数据与服务器进行通信
- ios客户端与java服务器进行通信
- 解如何利用 XML 和 JavaScript Object Notation 在 Ajax 客户端和 Java 服务器之间传输数据(代码)(Oracle)。
- android 客户端与服务器端之间采用JSON进行数据通信之一
- 利用jquery实现Ajax并用json2.js对返回的json进行转换操作