Get remote JSON data, a small summary of JA data

Source: Internet
Author: User

1.

If you want to get the data for HTTP://HQ.SINAJS.CN/RN=61FDJ&FORMAT=TEXT&LIST=STOCK_SH_UP_5MIN_20 output

Open the link, you can see the output is stock_sh_up_5min_20 = ...

That is, the server returns a section of JS code, so we create a local <script></script>, and the src equals the above link, like this:

<script src= "http://hq.sinajs.cn/rn=61fdj&format=text&list=stock_sh_up_5min_20" language= "JavaScript" ></script>

Then it's the equivalent of getting the data inside (although the variables are not our definition, but adding this script is the equivalent of defining the variables, and the scripts have these variables), and then we can use them, like this:

<script language= "JavaScript" >alert (stock_sh_up_5min_20[0].symbol) </script>

Like, there's this.

< Script type="text/javascript " src= " http://hq.sinajs.cn/list=sh601006 " charset="gb2312"></ script>
<script type= "text/javascript">
var elements=hq_str_sh601006.split (",");
document.write (" Current price:"+ ELEMENTS[3]);
</script>

2.

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.