<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>