Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-03 08:30:31 10月03日 Update

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!

Tags: Stock code price dynamic real-time technology data Sina content more knowledge practical lowest highest learned next code name name dilemma actual Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn Docker Shulou Tech Info OPPO Reno