Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use ajax technology to dynamically call Sina stock real-time data without refresh

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to use ajax technology to dynamically call Sina stock real-time data without refresh". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

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 iTun0; I yest_f). {$('# cymbicii) .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). {$('# franki) .html ("" + temp_f.toFixed (2) + "); $('# gobsi) .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); } ... .tr_cls {...}{ height:30px; font-size:16px; font-family:"Times New Roman", Times, serif; background-color:#FFFFCC } 股票代号 股票名称 当前价格 今日开盘 昨日收盘 当前差价 涨跌幅度 最高价格 最低价格 习惯用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)[xss_clean] = "" + curr_f + ""; } else if(curr_f < yest_f) ...{ $('c'+i)[xss_clean] = "" + curr_f + ""; } else ...{ $('c'+i)[xss_clean] = curr_f; } $('d'+i)[xss_clean] = tday_f; $('e'+i)[xss_clean] = yest_f; if(temp_f >

0). {$('franki) [xss_clean] = "" + temp_f.toFixed (2) + "; $(' temp_f / yest_f) [xss_clean] ="+ ((temp_f / yest_f) * 100) .tofixed (2) +"% ";} else if (temp_f < 0). {$('franki) [xss_clean] ="+ temp_f.toFixed (2) +" $('temp_f / yest_f) [xss_clean] = "" + ((temp_f / yest_f) * 100) .tofixed (2) + "%";} else... {$(' franki) [xss_clean] = temp_f.toFixed (2); $('groomi) [xss_clean] = ((temp_f / yest_f) * 100) .tofixed (2) + "%" } $('hype roomi) [xss_clean] = temp3.split (',') [4]; $(',') [xss_clean] = temp3.split (',') [5];}} function pageInit (). {window.setInterval ("ajaxRequest ()", 3000);} "how to use ajax technology to dynamically call Sina stock real-time data without refresh". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report