AG广东会,山东十一选五,大发

?
  • AG广东会400电话
  • 微网小程序
  • AI电话山东十一选五
  • 电商代运营
  • AG广东会,山东十一选五,大发:全 部 栏 目

    AG广东会400电话 网络优化推广 AI电话山东十一选五 呼叫中心 网站建设 商标?知产 微网小程序 电商运营 彩铃?短信 增值拓展业务
    使用ajax技术无刷新动态调用新浪股票实时数据

    新浪的财金频道一直感觉做得很好。但由于最近网速慢的缘故,查看股票信息时网页老是打不开。这几天一直在研究ajax,于是用jquery自己做了一个自动读取新浪股票实时数据的页面。

    html> 
    head> 
    title>ajax test/title> 
    meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    script type="text/javascript" src="jquery.js">/script> 
    script type="text/javascript">... 
    function ajaxRequest()...{ 
    $.ajax(...{ 
    url: 'http://hq.sinajs.cn/list=sh000001,sh601939,sh600016,sh600528,sh600667,sh601390,sh601398,sh601857,sh600028', 
    type: 'GET', 
    dataType: 'html', 
    timeout: 2000, 
    success: function(response)...{ 
    var stocks = response.split(';'); 
    for(var i=0; istocks.length-1; i++)...{ 
    var content = stocks[i]; 
    var temp1 = content.split('=')[0]; 
    var temp2 = content.split('=')[1]; 
    var code = temp1.substr(temp1.length - 6, 6); 
    var temp3 = temp2.replace('"', ''); 
    var name = temp3.split(',')[0]; 
    var tday_f = temp3.split(',')[1]; 
    var yest_f = temp3.split(',')[2]; 
    var curr_f = temp3.split(',')[3]; 
    var temp_f = curr_f - yest_f; 
    $('#a'+i).html(code); 
    $('#b'+i).html(name); 
    if(curr_f > yest_f) ...{ 
    $('#c'+i).html("font color='red'>" + curr_f + "/font>"); 
    } else if(curr_f  yest_f) ...{ 
    $('#c'+i).html("font color='green'>" + curr_f + "/font>"); 
    } else ...{ 
    $('#c'+i).html(curr_f); 
    } 
    $('#d'+i).html(tday_f); 
    $('#e'+i).html(yest_f); 
    if(temp_f > 0) ...{ 
    $('#f'+i).html("font color='red'>" + temp_f.toFixed(2) + "/font>"); 
    $('#g'+i).html("font color='red'>" + ((temp_f / yest_f) * 100).toFixed(2) + "/font> % "); 
    } else if(temp_f  0) ...{ 
    $('#f'+i).html("font color='green'>" + temp_f.toFixed(2) + "/font>"); 
    $('#g'+i).html("font color='green'>" + ((temp_f / yest_f) * 100).toFixed(2) + "/font> % "); 
    } 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); 
    } 
    /script> 
    style>... 
    .tr_cls {...}{ 
    height:30px; 
    font-size:16px; 
    font-family:"Times New Roman", Times, serif; 
    background-color:#FFFFCC 
    } 
    /style> 
    /head> 
    body >/span>/td> 
    /tr> 
    /table> 
    /form> 
    /body> 
    /html>

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

    script type="text/javascript" src="prototype.js">/script> 
    script type="text/javascript">... 
    function ajaxRequest()...{ 
    var myAjax = new Ajax.Request( 
    'http://hq.sinajs.cn/list=sh000001,sh601939,sh600016,sh600528,sh600667,sh601390,sh601398,sh601857,sh600028', 
    ...{ 
    method: 'get', 
    onComplete: setData 
    } 
    ); 
    } 
    function setData(response) ...{ 
    var contents = response.responseText; 
    var stocks = contents.split(';'); 
    for(var i=0; istocks.length-1; i++)...{ 
    var content = stocks[i]; 
    var temp1 = content.split('=')[0]; 
    var temp2 = content.split('=')[1]; 
    var code = temp1.substr(temp1.length - 6, 6); 
    var temp3 = temp2.replace('"', ''); 
    var name = temp3.split(',')[0]; 
    var tday_f = temp3.split(',')[1]; 
    var yest_f = temp3.split(',')[2]; 
    var curr_f = temp3.split(',')[3]; 
    var temp_f = curr_f - yest_f; 
    $('a'+i).innerHTML = code; 
    $('b'+i).innerHTML = name; 
    $('c'+i).innerHTML = curr_f; 
    if(curr_f > yest_f) ...{ 
    $('c'+i).innerHTML = "font color='red'>" + curr_f + "/font>"; 
    } else if(curr_f  yest_f) ...{ 
    $('c'+i).innerHTML = "font color='green'>" + curr_f + "/font>"; 
    } else ...{ 
    $('c'+i).innerHTML = curr_f; 
    } 
    $('d'+i).innerHTML = tday_f; 
    $('e'+i).innerHTML = yest_f; 
    if(temp_f > 0) ...{ 
    $('f'+i).innerHTML = "font color='red'>" + temp_f.toFixed(2) + "/font>"; 
    $('g'+i).innerHTML = "font color='red'>" + ((temp_f / yest_f) * 100).toFixed(2) + "/font> %"; 
    } else if(temp_f  0) ...{ 
    $('f'+i).innerHTML = "font color='green'>" + temp_f.toFixed(2) + "/font>"; 
    $('g'+i).innerHTML = "font color='green'>" + ((temp_f / yest_f) * 100).toFixed(2) + "/font> %"; 
    } 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); 
    } 
    /script>

    当然页面部分完全可以由脚本自动生成,以及页面动态增减股票信息等功能,就等日后修改吧。

    您可能感兴趣的文章:
    • ThinkPHP结合AjaxFileUploader实现无刷新文件上传的方法
    • Jquery基于Ajax方法自定义无刷新提交表单Form实例
    • 使用ajax实现无刷新改变页面内容和地址栏URL
    • php+ajax实现无刷新动态加载数据技术
    • jQuery+AJAX实现无刷新下拉加载更多
    • jQuery实现AJAX定时刷新局部页面实例
    • jQuery使用$.ajax进行异步刷新的方法(附demo下载)
    • jQuery实现form表单基于ajax无刷新提交方法详解
    • jQuery+Ajax实现无刷新操作
    • 分页技术原理与实现之无刷新的Ajax分页技术(三)
    • Ajax回退刷新页面问题的解决办法
    上一篇:如何创建ajax对象并兼容多个浏览器
    下一篇:AJAX验证数据库内容并将值显示在页面
  • 相关文章
  • ?

    ? 2016-2020 巨人网络通讯 版权所有

    《增值电信业务经营许可证》 苏ICP备15040257号-8

    使用ajax技术无刷新动态调用新浪股票实时数据 使用,ajax,技术,无,刷新,

    AG广东会官网入口(中国)官方网站-IOS/Android通用版(2026已更新)