<div class="codetitle"> <span><a style="CURSOR: pointer" data="28927" class="copybut" id="copybut28927" onclick="doCopy('code28927')"><u>コードをコピー</u></a></span> コードは次のとおりです:</div> <div class="codebody" id="code28927"> <br><html> <br> <br><title>ajax テスト</title> <br><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <br><script type="text/javascript" src="jquery.js"></script> <br><script type="text/javascript">... <br>function ajaxRequest()...{ <br>var url = $("#stockurl").val() $("#ストックイット").val(); <br>$.ajax(...{ <br>url: url, <br>type: 'GET', <br>dataType: 'html', <br>timeout: 2000, <br>success: function(応答)...{ <br>varstocks = response.split(';') <br>for(var i=0; i<stocks.length-1 i>var content = 株式[i]; <br>var temp1 = content.split('=')[0]; <br>var temp2 = content.split('=')[1]; <br>var code = temp1。 substr(temp1.length - 6, 6); <br>var temp3 = temp2.replace('"', ''); <br>var name = temp3.split(',')[0]; <br> var tday_f = temp3.split(',')[1]; <br>var yest_f = temp3.split(',')[2]; <br>var curr_f = temp3.split(',')[3] ; <br>var temp_f = curr_f - yest_f; <br><br>$('#a' i).html(code); <br>$('#b' i); >if(curr_f > yest_f) ...{ <br>$('#c' i).html("<font color='red'>" curr_f "</font>"); >} else if(curr_f <yest_f) ...{ <BR>$('#c' i).html("<font color='green'>" curr_f "</font>"); <br>} else ...{ <br>$('#c' i).html(curr_f); <br>} <br>$('#d' i).html(tday_f); $('#e' i).html(yest_f); <br>if(temp_f > 0) ...{ <br>$('#f' i).html("<font color='red '>" temp_f.toFixed(2) "</font>"); <br>$('#g' i).html("<font color='red'>" ((temp_f / yest_f) * 100).toFixed(2) "</font> % "); <BR>} else if(temp_f < 0) ...{ <BR>$('#f' i).html("<font color='green'>" temp_f.toFixed(2) "< ;/font>"); <br>$('#g' i).html("<font color='green'>" ((temp_f / yest_f) * 100).toFixed(2) "</font> % "); <BR>} else ...{ <BR>$('#f' i).html(temp_f.toFixed(2)); <BR>$('#g' i).html(((temp_f / yest_f) * 100).toFixed(2) " % "); <BR>} <BR>$('#h' i).html(temp3.split(',')[4]); <BR>$('#i' i).html(temp3.split(',')[5]); <BR>} <BR>} <BR>}); <BR>} <BR><BR>$(document).ready(function()...{ <BR><br>varstocks = $("#stockinit").val().split(',' ); <br>for(var i=0; i<stocks.length; i )...{ <br>addRows() <br>} <BR><BR>$("#insrow") (function()...{ <BR><br>varstockcd = $("#stockid").val(); <br>if(stockcd == "")...{ <br>alert(" "); <br>$("#stockid").focus(); <BR>return; <BR>} <BR>if(stockcd.length != 6)...{ <BR>alert("股票代号只能是6位!"); <BR>$("#stockid").focus(); <BR>return; <BR>} <BR>var div = 'sh'; <BR>if(document.getElementById("sz_id") .checked)...{ div = "sz";} <BR>varstocks = $("#stockinit").val(); <BR>$("#stockinit").val(stocks "," div Stockcd); <BR>addRows(); <BR>}); <br><br>$("#delrow").click(function()...{ <BR>var table = document.getElementById(" tableId"); <BR>varindex = table.rows.length; <BR>if (index < 2)...{ <BR>alert("已经没有可删除的行了!"); <BR> } else ...{ <BR>table.deleteRow(index - 1); <BR>varstockvalue = $("#stockinit").val(); <BR>var count =stockvalue.split(',') .length; <BR>if(count == 1) ...{ <BR>stockvalue = ""; <BR>} else ...{ <BR>stockvalue = Stockvalue.length - 9 ); <BR>} <BR>$("#stockinit").val(stockvalue) <BR>} <BR>}); <br><br>window.setInterval("ajaxRequest()",3000) ; <BR>}); <br><br>関数 addRows()...{ <BR>var table = document.getElementById("tableId"); >var str=""; <BR>var row = インデックス - 1; <BR>str ='<tr class="tr_cls">' <BR>str ='<td align="center"><span id="' "a" row '"></span></td>' <br>str ='<td align="center"><span id="' "b" row '"></span></td>' <br>str ='<td align="center"><span id="' "c" row '"></span></td>' <br>str ='<td align="center"><span id="' "d" row '"></span></td>' <br>str ='<td align="center"><span id="' "e" row '"></span></td>' <br>str ='<td align="center"><span id="' "f" row '"></span></td>' <br>str ='<td align="center"><span id="' "g" row '"></span></td>' <br>str ='<td align="center"><span id="' "h" row '"></span></td>' <br>str ='<td align="center"><span id="' "i" row '"></span></td>' <br>str ='</tr>'; <br>$("#tablebody").append(str); <br></script> . <br>.tr_cls {...}{ <br>height:30px; <br>font-size:16px; <br>font-family:"Times New Roman"、タイムズ、セリフ- color:#FFFFCC <br>} <br></style> <br><body> <br><input type="hidden" ="stockurl" value="http://hq.sinajs.cn/list=" /> <br><input type="hidden" id="stockinit" value="sh000001,sz399001,sh601939,sh600016, sh600528,sh600667,sh601390,sh601857,sz000532,sh600019,sh601111,sh601600,sh601006,sh601333,sh601398,sh601988,sh601328" /> <br><テーブル幅="8 00" border="0" align="center" cellpadding="0" cellpacing="0" > <br><tr> <br>代号:<input type="text" id="stockid" size="6"> <br><td width="150px"> <br> 区別:上海<input type="radio" name="rad" id=" sh_id" チェック済み>深证<input type="radio" name="rad" id="sz_id"> <br></td> <br><td width="40px"> <br> <input type="button" id="insrow" value="行追加"> <br></td> <br><td width="495px"> <br><input type="button" id="delrow" value="行削除"> <br></td> <br></tr> <br><tr> <br><tdcolspan="4"> <br><div style="overflow-y:scroll; overflow-x:auto; height:392px; width:817px"> <BR><table id="tableId" width="800" border="1" align="center" cellpadding="0" cellpacing="0" bordercolor="#000000"> <br><tr bgcolor="#3399FF" height="30px"> <br><thscope="col">股票代号</th> <br><thscope="col">股票名</th> <br><thscope="col">当前价格</th> <br><thscope="col">今日开盘</th> <br><thscope="col">昨日收盘</th> <br><thscope="col">現在差价</th> <br><thscope="col">涨跌幅</th> <br><thscope="col">最高价格</th> <br><thscope="col">最低价格</th> <br></tr> <br><tbody id="tablebody"> <br></tbody> <br></table> <br> <br></td> <br></tr> <br></table> <br></form> <br></body> <br></html><br><br> </tr></stocks.length-1> </div>