无为清净楼资源网 Design By www.qnjia.com
复制代码 代码如下:
<html>
<head>
<title>ajax test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery.js"><script type="text/javascript">...
function ajaxRequest()...{
var url = $("#stockurl").val() + $("#stockinit").val();
$.ajax(...{
url: url,
type: 'GET',
dataType: 'html',
timeout: 2000,
success: function(response)...{
var stocks = response.split(';');
for(var i=0; i<stocks.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]);
}
}
});
}
$(document).ready(function()...{
var stocks = $("#stockinit").val().split(',');
for(var i=0; i<stocks.length; i++)...{
addRows();
}
$("#insrow").click(function()...{
var stockcd = $("#stockid").val();
if(stockcd == "")...{
alert("股票代号不能为空!");
$("#stockid").focus();
return;
}
if(stockcd.length != 6)...{
alert("股票代号只能是6位!");
$("#stockid").focus();
return;
}
var div = 'sh';
if(document.getElementById("sz_id").checked)...{ div = "sz";}
var stocks = $("#stockinit").val();
$("#stockinit").val(stocks + "," + div + stockcd);
addRows();
});
$("#delrow").click(function()...{
var table = document.getElementById("tableId");
var index = table.rows.length;
if (index < 2)...{
alert("已经没有可删除的行了!");
} else ...{
table.deleteRow(index - 1);
var stockvalue = $("#stockinit").val();
var count = stockvalue.split(',').length;
if(count == 1) ...{
stockvalue = "";
} else ...{
stockvalue = stockvalue.substr(0, stockvalue.length - 9);
}
$("#stockinit").val(stockvalue);
}
});
window.setInterval("ajaxRequest()",3000);
});
function addRows()...{
var table = document.getElementById("tableId");
var index = table.rows.length;
var str="";
var row = index - 1;
str+='<tr class="tr_cls">'
str+='<td align="center"><span id="' + "a" + row + '"></span></td>'
str+='<td align="center"><span id="' + "b" + row + '"></span></td>'
str+='<td align="center"><span id="' + "c" + row + '"></span></td>'
str+='<td align="center"><span id="' + "d" + row + '"></span></td>'
str+='<td align="center"><span id="' + "e" + row + '"></span></td>'
str+='<td align="center"><span id="' + "f" + row + '"></span></td>'
str+='<td align="center"><span id="' + "g" + row + '"></span></td>'
str+='<td align="center"><span id="' + "h" + row + '"></span></td>'
str+='<td align="center"><span id="' + "i" + row + '"></span></td>'
str+='</tr>';
$("#tablebody").append(str);
}
</script>
<style>...
.tr_cls {...}{
height:30px;
font-size:16px;
font-family:"Times New Roman", Times, serif;
background-color:#FFFFCC
}
</style>
</head>
<body>
<form>
<input type="hidden" id="stockurl" value="http://hq.sinajs.cn/list=" />
<input type="hidden" id="stockinit" value="sh000001,sz399001,sh601939,sh600016,sh600528,sh600667,sh601390,sh601857,sz000532,sh600019,sh601111,sh601600,sh601006,sh601333,sh601398,sh601988,sh601328" />
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td width="115px">
代号:<input type="text" id="stockid" size="6">
</td>
<td width="150px">
区分:上海<input type="radio" name="rad" id="sh_id" checked>深证<input type="radio" name="rad" id="sz_id">
</td>
<td width="40px">
<input type="button" id="insrow" value="行追加">
</td>
<td width="495px">
<input type="button" id="delrow" value="行削除">
</td>
</tr>
<tr>
<td colspan="4">
<div style="overflow-y:scroll; overflow-x:auto; height:392px; width:817px">
<table id="tableId" width="800" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr bgcolor="#3399FF" height="30px">
<th scope="col">股票代号</th>
<th scope="col">股票名称</th>
<th scope="col">当前价格</th>
<th scope="col">今日开盘</th>
<th scope="col">昨日收盘</th>
<th scope="col">当前差价</th>
<th scope="col">涨跌幅度</th>
<th scope="col">最高价格</th>
<th scope="col">最低价格</th>
</tr>
<tbody id="tablebody">
</tbody>
</table>
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<title>ajax test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery.js"><script type="text/javascript">...
function ajaxRequest()...{
var url = $("#stockurl").val() + $("#stockinit").val();
$.ajax(...{
url: url,
type: 'GET',
dataType: 'html',
timeout: 2000,
success: function(response)...{
var stocks = response.split(';');
for(var i=0; i<stocks.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]);
}
}
});
}
$(document).ready(function()...{
var stocks = $("#stockinit").val().split(',');
for(var i=0; i<stocks.length; i++)...{
addRows();
}
$("#insrow").click(function()...{
var stockcd = $("#stockid").val();
if(stockcd == "")...{
alert("股票代号不能为空!");
$("#stockid").focus();
return;
}
if(stockcd.length != 6)...{
alert("股票代号只能是6位!");
$("#stockid").focus();
return;
}
var div = 'sh';
if(document.getElementById("sz_id").checked)...{ div = "sz";}
var stocks = $("#stockinit").val();
$("#stockinit").val(stocks + "," + div + stockcd);
addRows();
});
$("#delrow").click(function()...{
var table = document.getElementById("tableId");
var index = table.rows.length;
if (index < 2)...{
alert("已经没有可删除的行了!");
} else ...{
table.deleteRow(index - 1);
var stockvalue = $("#stockinit").val();
var count = stockvalue.split(',').length;
if(count == 1) ...{
stockvalue = "";
} else ...{
stockvalue = stockvalue.substr(0, stockvalue.length - 9);
}
$("#stockinit").val(stockvalue);
}
});
window.setInterval("ajaxRequest()",3000);
});
function addRows()...{
var table = document.getElementById("tableId");
var index = table.rows.length;
var str="";
var row = index - 1;
str+='<tr class="tr_cls">'
str+='<td align="center"><span id="' + "a" + row + '"></span></td>'
str+='<td align="center"><span id="' + "b" + row + '"></span></td>'
str+='<td align="center"><span id="' + "c" + row + '"></span></td>'
str+='<td align="center"><span id="' + "d" + row + '"></span></td>'
str+='<td align="center"><span id="' + "e" + row + '"></span></td>'
str+='<td align="center"><span id="' + "f" + row + '"></span></td>'
str+='<td align="center"><span id="' + "g" + row + '"></span></td>'
str+='<td align="center"><span id="' + "h" + row + '"></span></td>'
str+='<td align="center"><span id="' + "i" + row + '"></span></td>'
str+='</tr>';
$("#tablebody").append(str);
}
</script>
<style>...
.tr_cls {...}{
height:30px;
font-size:16px;
font-family:"Times New Roman", Times, serif;
background-color:#FFFFCC
}
</style>
</head>
<body>
<form>
<input type="hidden" id="stockurl" value="http://hq.sinajs.cn/list=" />
<input type="hidden" id="stockinit" value="sh000001,sz399001,sh601939,sh600016,sh600528,sh600667,sh601390,sh601857,sz000532,sh600019,sh601111,sh601600,sh601006,sh601333,sh601398,sh601988,sh601328" />
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td width="115px">
代号:<input type="text" id="stockid" size="6">
</td>
<td width="150px">
区分:上海<input type="radio" name="rad" id="sh_id" checked>深证<input type="radio" name="rad" id="sz_id">
</td>
<td width="40px">
<input type="button" id="insrow" value="行追加">
</td>
<td width="495px">
<input type="button" id="delrow" value="行削除">
</td>
</tr>
<tr>
<td colspan="4">
<div style="overflow-y:scroll; overflow-x:auto; height:392px; width:817px">
<table id="tableId" width="800" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr bgcolor="#3399FF" height="30px">
<th scope="col">股票代号</th>
<th scope="col">股票名称</th>
<th scope="col">当前价格</th>
<th scope="col">今日开盘</th>
<th scope="col">昨日收盘</th>
<th scope="col">当前差价</th>
<th scope="col">涨跌幅度</th>
<th scope="col">最高价格</th>
<th scope="col">最低价格</th>
</tr>
<tbody id="tablebody">
</tbody>
</table>
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
标签:
ajax,无刷新,动态调用
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年11月06日
2024年11月06日
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]