jQuery Ajax 实例演示-获取json数据
2012-02-23 20:49
441 查看
<html> <head> <title>jQuery Ajax 实例演示</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> </head> <script src="http://code.jquery.com/jquery-1.4.3.js"></script> <script type="text/javascript"> //方式一 //$.getJSON("http://audicms.ogilvy.com.cn/webapp/front/dealerapi!getdealerlist.action",function(data){alert(data);}); //方式二 //$.get("http://audicms.ogilvy.com.cn/webapp/front/dealerapi!getdealerlist.action","",function(data){alert(data);}); //$.each(dataObj.dealers, function(i, v){$("#success").append(v.name).append("<br/>");document.getElementById("result").innerHTML+=v.name+"<br/>";})}); //方式三 $.ajax({ type: "POST",//请求方式 url: "http://audicms.ogilvy.com.cn/webapp/front/dealerapi!getdealerlist.action",//地址,就是action请求路径 data: "json",//数据类型text xml json script jsonp success: function(msg){//返回的参数就是 action里面所有的有get和set方法的参数 //$.each(msg.items, function(i,item){}); var dataObj=eval("("+msg+")"); alert(dataObj.dealers.length); document.getElementById("result").innerHTML=msg; } }); </script> <body> <div id="result" style="background:orange;border:1px solid red;width:300px;height:200px;"></div> <form id="formtest" action="" method="post"> <span id="result"></span> </form> </body> </html>
相关文章推荐
- jQuery Ajax 实例演示-获取json数据
- Jquery Ajax和getJSON获取后台普通Json数据和层级Json数据解析
- AJAX跨域请求JSONP获取JSON数据的实例代码
- Ajax获取php返回json数据动态生成select下拉框的实例
- JavaWeb将数据包装成JSON以及JSP通过ajax对JSON的获取与解析(代码实例)
- Jquery Ajax 学习实例2 向页面发出请求 返回JSon格式数据
- .Net MVC3之2:前台异步获取json数据的实例(2)
- vue2.5.2使用http请求获取静态json数据的实例代码
- ajax跨域获取网站json数据的实例
- jquery ajax 获取数据 转换成 Json
- JavaWeb将数据包装成JSON以及JSP通过ajax对JSON的获取与解析(代码实例)
- jquery Ajax 方法返回数据的获取,包括JSON,XML,TXT
- Android网络编程之获取网络上的Json数据实例
- jquery Ajax 方法返回数据的获取,包括JSON,XML,TXT
- jquery ajax post方法获取json数据
- Ajax获取PHP服务器上的 Json数据以及POST的综合实例
- JQuery 获取json数据$.getJSON方法的实例代码
- jquery ajax请求返回xml,html,text,json,..数据实例详解
- 获取服务端页面JSON数据的JQUERY ajax方法定义
- Ajax获取PHP服务器上的 Json数据以及POST的综合实例