如何使用ajax技术无刷新动态调用新浪股票实时数据-创新互联

本篇内容介绍了“如何使用ajax技术无刷新动态调用新浪股票实时数据”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

创新互联是一家专业提供米易企业网站建设,专注与网站设计、成都网站建设html5、小程序制作等业务。10年已为米易众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。
 
 
ajax test 
 
 
... 
function ajaxRequest()...{ 
$.ajax(...{ 
url: 'http://hq.sinajs.cn/list=sh000001,sh701939,sh700016,sh700528,sh700667,sh701390,sh701398,sh701857,sh700028', 
type: 'GET', 
dataType: 'html', 
timeout: 2000, 
success: function(response)...{ 
var stocks = response.split(';'); 
for(var i=0; i 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()",3000); 
} 
 
 
 
 
      股票代号  股票名称  当前价格  今日开盘  昨日收盘  当前差价  涨跌幅度  高价格  最低价格                                                                                                                                                                                                               

习惯用prototype的,把脚本部分的代码替换一下即可。
复制代码 代码如下:

 
... 
function ajaxRequest()...{ 
var myAjax = new Ajax.Request( 
'http://hq.sinajs.cn/list=sh000001,sh701939,sh700016,sh700528,sh700667,sh701390,sh701398,sh701857,sh700028', 
...{ 
method: 'get', 
onComplete: setData 
} 
); 
} 
function setData(response) ...{ 
var contents = response.responseText; 
var stocks = contents.split(';'); 
for(var i=0; i yest_f) ...{ 
$('c'+i).innerHTML = "" + curr_f + ""; 
} else if(curr_f < yest_f) ...{ 
$('c'+i).innerHTML = "" + curr_f + ""; 
} else ...{ 
$('c'+i).innerHTML = curr_f; 
} 
$('d'+i).innerHTML = tday_f; 
$('e'+i).innerHTML = yest_f; 
if(temp_f > 0) ...{ 
$('f'+i).innerHTML = "" + temp_f.toFixed(2) + ""; 
$('g'+i).innerHTML = "" + ((temp_f / yest_f) * 100).toFixed(2) + " %"; 
} else if(temp_f < 0) ...{ 
$('f'+i).innerHTML = "" + temp_f.toFixed(2) + ""; 
$('g'+i).innerHTML = "" + ((temp_f / yest_f) * 100).toFixed(2) + " %"; 
} else ...{ 
$('f'+i).innerHTML = temp_f.toFixed(2); 
$('g'+i).innerHTML = ((temp_f / yest_f) * 100).toFixed(2) + " % "; 
} 
$('h'+i).innerHTML = temp3.split(',')[4]; 
$('i'+i).innerHTML = temp3.split(',')[5]; 
} 
} 
function pageInit() ...{ 
window.setInterval("ajaxRequest()",3000); 
} 

“如何使用ajax技术无刷新动态调用新浪股票实时数据”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!


名称栏目:如何使用ajax技术无刷新动态调用新浪股票实时数据-创新互联
标题来源:http://csdahua.cn/article/doehgp.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流