http://www.cnblogs.com/chopper/archive/2012/03/24/2403945.html
总结一下:
1. 使用script tag实现跨域访问
本地建立2个http server:A(localhost:20001)和B(localhost:20002)
用户使用浏览器访问A的index.html, test.js保存在B中
index.html如下:
<html >
<head>
<title>test</title>
<script>
function callback(data) {
alert(data.message);
}
</script>
<script type="text/javascript" src="http://localhost:20002/test.js"></script>
</head>
<body>
</body>
</html>
test.js如下:
callback({message:"success"});
运行结果:弹出“success”的对话框
2. 客户端和服务端规定JSONP协议,完成跨域数据传输