Get stock real-time data asynchronously via jquery

Source: Internet
Author: User
Tags getscript

Recently my friend asked me to help him do an asynchronous data acquisition program, temporary server Nothing, so I would like to take stock data frame, easy to follow up development and transplant and other things

The code is as follows:

<!--Description: Stock Watch Spades a time: 2014-04-14 reference: http://www.lxway.com/240649562.htmhttp://www.lxway.com/946486042.htmhttp:// www.365mini.com/page/jquery_getscript.htmhttp://blog.csdn.net/xxjoy_777/article/details/40304935http:// Www.jb51.net/article/54253.htm -<!DOCTYPE HTML><HTML><Head>    <title></title>    <styletype= "Text/css">Div{Height:20px;Widows:20px;font-size:26px;Font-weight:Bold;        }    </style>        <Scripttype= "Text/javascript"src= "./jquery1.11.js"></Script>    </Head><Body>    <DivID= "res"></Div><BR/><BR/><BR/>    <DivID= "Div1">HELLO WORLD0</Div>    <DivID= "Div2">HELLO WORLD2</Div>    <BR/>    <ButtonID= "BTN">Click Me</Button><BR/><BR/>        <Scripttype= "Text/javascript">        functionPageinit () {//This method needs to add the following code in the body: <body onload= "Pageinit ();" >        //Window.setinterval ("Ajaxrequest ()", 3000); Set the method for timing calls to Ajax, in milliseconds, 1000 milliseconds =1 seconds} $ (document). Ready (function(){        varURL= "http://hq.sinajs.cn/list=sh601006,sh601939,sh600016"; //returns the form data of Var hq_str_sh601006= "xxxxxxx". URL="Http://api.money.126.net/data/feed/1000002,1000001,1000881,money.api"; //returns the form data for _ntes_quote_callback ({xxxx});         //url= "Http://flashquote.stock.hexun.com/Stock_Combo.ASPX?mc=1_600804&dt=T"; Returns the form data for RefreshData (xxxxxxx). getnewdata (URL); varTG=Self.setinterval ("Getnewdata ('"+URL+"')", -);//n milliseconds refreshed, in milliseconds, 1000 milliseconds =1 secConsole.log ("DDD")    }); //Get new Data    functiongetnewdata (URL) {varDurl=URL//+ "&t=" +math.random ();                //Way One: Get the data through Ajax$.ajax ({cache:true, Url:url, type:'GET', DataType:'Script', timeout: -, Success:function(data, Textstatus, JQXHR) {varStr=data; STR=Hq_str_sh600016.split (','); $("#res")[0].innertext=str[ -]+" "+str[ to]+"Ajax"; Console.log ("FAFAFAF");                        }        }); /*//Mode two: Get the data by Getscript, if the variables in the script must be set $.ajaxsetup ({cache:true});         $.ajaxsetup ({cache:true});            $.getscript (data) {///load the script and execute the obtained script data, you can call the variables in the load script and so on str = Hq_str_sh600016.split (', ');            $ ("#res") [0].innertext=str[30]+ "" +str[31]+ "Ajax";        Console.log ("Getnewdata")}); */            }        function_ntes_quote_callback (data) {$ ("#res")[0].innertext=data[1000002].time+"Callback"; }        //document.getElementById (' btn '). AddEventListener (' click ', t1);         </Script></Body></HTML>

Get stock real-time data asynchronously via jquery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.