用JS或者AJAX 的方法远程读取信息

[{"aa":a1,"bb":"22","cc":"33","dd":"44","ee":0},{"aa":a2,"bb":"22","cc":"33","dd":"44... [{"aa":a1,"bb":"22","cc":"33","dd":"44","ee":0},{"aa":a2,"bb":"22","cc":"33","dd":"44","ee":0},{"aa":a3,"bb":"22","cc":"33","dd":"44","ee":0},{"aa":a4,"bb":"22","cc":"33","dd":"44","ee":0},{"a5":a3,"bb":"22","cc":"33","dd":"44","ee":0}......]
......的意思是后面还有很多组这样的数
以上为远程页面的信息
http://127.0.0.1/1.asp?yy=a

请问如何用 JS或者AJAX 截取或者调用此页面 然后进行裁剪
页面得到
a1,a2,a3,a4,a5
效果
[{"aa":a1,"bb":"223","cc":"334","dd":"423","ee":0},{"aa":a2,"bb":"2d2","cc":"3343","dd":"44e","ee":0},{"aa":a3,"bb":"2223","cc":"3xx","dd":"443","ee":0},{"aa":a4,"bb":"225","cc":"3a3","dd":"444","ee":0},{"aa":a5,"bb":"2f2","cc":"3g3","dd":"44w","ee":0}......]
刚才的代码错了 应该是这样
展开
 我来答
zhangbo99_net
2010-01-29 · TA获得超过1465个赞
知道大有可为答主
回答量:922
采纳率:0%
帮助的人:1228万
展开全部
先说明:
a1,a2,a3,a4,a5,在返回的字符串中应该加",否则js会报错.除非在你的环境里,a1,...a5是已经定义的变量.

以下是使用代码.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>

<script type="text/javascript">

function handler() {
var result = '[{"aa":"a1","bb":"223","cc":"334","dd":"423","ee":0},{"aa":"a2","bb":"2d2","cc":"3343","dd":"44e","ee":0},{"aa":"a3","bb":"2223","cc":"3xx","dd":"443","ee":0},{"aa":"a4","bb":"225","cc":"3a3","dd":"444","ee":0},{"aa":"a5","bb":"2f2","cc":"3g3","dd":"44w","ee":0}]';
//这里演示的是服务器返回的数据,字符串形式.这方法在回调函数中使用.在实例使用时,result应该替换为服务器返回的数据.

var resultjson = eval(result);

var div = document.getElementById("info");
for (var i = 0; i < resultjson.length; i++) {

div.innerHTML += resultjson[i].aa;
if (i < resultjson.length - 1) {
div.innerHTML += ",";
}
}
}
window.onload = handler;

</script>

</head>
<body>

<div id="info">

</div>

</body>
</html>
kxl361
2010-01-29 · TA获得超过393个赞
知道小有建树答主
回答量:686
采纳率:0%
帮助的人:864万
展开全部
你用ajax获取以后,就可以直接用了。

var json = [{"aa":a1,"bb":"223","cc":"334","dd":"423","ee":0},{"aa":a2,"bb":"2d2","cc":"3343","dd":"44e","ee":0},{"aa":a3,"bb":"2223","cc":"3xx","dd":"443","ee":0},{"aa":a4,"bb":"225","cc":"3a3","dd":"444","ee":0},{"aa":a5,"bb":"2f2","cc":"3g3","dd":"44w","ee":0}......];
json[0] = {"aa":a1,"bb":"223","cc":"334","dd":"423","ee":0};
json[0].aa = a1;
json[0].bb = "223";
...
...

以此类推。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式