ajax+新浪股票,使用ajax技术无刷新动态调用新浪股票实时数据.doc

使用ajax技术无刷新动态调用新浪股票实时数据

使用ajax技术无刷新动态调用新浪股票实时数据

由于最近网速慢的缘故,查看股票信息时网页老是打不开。这几天一直在研究ajax,于是用jquery自己做了一个自动读取新浪股票实时数据的页面

新浪的财金频道一直感觉做得很好。但由于最近网速慢的缘故,查看股票信息时网页老是打不开。这几天一直在研究ajax,于是用jquery自己做了一个自动读取新浪股票实时数据的页面。

ajax test

function ajaxRequest()...{

$.ajax(...{

url: '/list=sh000001,sh601939,sh600016,sh600528,sh600667,sh601390,sh601398,sh601857,sh600028',

type: 'GET',

dataType: 'html',

timeout: 2000,

success: function(response)...{

var stocks = response.split(';');

for(var i=0; i

var content = stocks[i];

var temp1 = content.split('=')[0];

var temp2 = content.split('=')[1];

var code = temp1.substr(temp1.length - 6, 6);

var temp3 = temp2.replace('"', '');

var name = temp3.split(',')[0];

var tday_f = temp3.split(',')[1];

var yest_f = temp3.split(',')[2];

var curr_f = temp3.split(',')[3];

var temp_f = curr_f - yest_f;

$('#a'+i).html(code);

$('#b'+i).html(name);

if(curr_f > yest_f) ...{

$('#c'+i).html("" + curr_f + "");

} else if(curr_f < yest_f) ...{

$('#c'+i).html("" + curr_f + "");

} else ...{

$('#c'+i).html(curr_f);

}

$('#d'+i).html(tday_f);

$('#e'+i).html(yest_f);

if(temp_f > 0) ...{

$('#f'+i).html("" + temp_f.toFixed(2) + "");

$('#g'+i).html("" + ((temp_f / yest_f) * 100).toFixed(2) + " % ");

} else if(temp_f < 0) ...{

$('#f'+i).html("" + temp_f.toFixed(2) + "");

$('#g'+i).html("" + ((temp_f / yest_f) * 100).toFixed(2) + " % ");

} else ...{

$('#f'+i).html(temp_f.toFixed(2));

$('#g'+i).html(((temp_f / yest_f) * 100).toFixed(2) + " % ");

}

$('#h'+i).html(temp3.split(',')[4]);

$('#i'+i).html(temp3.split(',')[5]);

}

}

});

}

function pageInit() ...{

window.setInterval("ajaxRequest()"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值