我做了一个 javascript 来为列表框绘制一个值列表。 值来自 SQL 服务器
的数据库。 当我对数据库中的值做一些修改时, 我的列表框中的值不会更新。 看起来浏览器会缓存值或其它东西, 因为当我清除浏览器上的缓存时, 列表框更新中的值 。
这是我的笔记本(authapp.js):
$(document).ready(function(){
$(window).load(function(){
var loads = <table> +
<tr> +
<td align="center" class="label"> +
<img src="../../../Images/loading.gif" alt="Please wait..."
align="middle" style="width:30px;height:30px;"> +
</td> +
</tr> +
<tr> +
<td align="center" class="label"> +
<font color="#FFFFFF" face="Arial, Helvetica, sans-serif">Loading...</font> +
</td> +
</tr> +
</table> ;
//load selected customer
$.ajax({
type: "GET",
url: "master/authtpl/queries/get_sel_cust.asp",
data: "cunit="+$( #cunit ).val()+"&ccduser="+$( #ccduser ).val(),
beforeSend: function(){
$( #load_sel ).block({
message: loads,
css: { border: none ,
top: 10% ,
width: 10% ,
backgroundColor: #606060 ,
opacity: 0.3
}
});
},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) {
$( #load_sel ).unblock();
if(response==undefined){
alert( List q of Selected Customer is not available! );
} else {
$( #selSelected ).empty();
var cust = (typeof response.cust) == string ? eval( ( + response.cust + ) ) : response.cust;
// get data from json
var count = 0,strs = ;
lent = cust.length;
do {
strs += <option value=" +cust[count].ckode+ | +cust[count].cgrup+ | +cust[count].cnama+ "> +cust[count].ckode+ - +cust[count].cnama;
count++;
} while (count < lent);
$( #selSelected ).append(strs);
}
}
});
});
});
这是我的查询来获得这个值 (get_sel_cust.asp):
<!-- #INCLUDE file = "../../../include/createconnection.asp" -->
<%
dwdb = Application("DWDB")
ccdappl = Application("CCDAPPL")
ckdunitkey = trim(Request.QueryString("cunit"))
ccduser = trim(Request.QueryString("ccduser"))
sql = "select distinct ckdrelasi,ckdgruprelasi,vnamarelasi "&_
"from " & dwdb & ".dwaustasia.dbo.ms_webuser_apprtpl "&_
"where ckdunitkey= "&ckdunitkey&" and ccduser= "&ccduser&" and ccdappl= "&ccdappl&" "&_
"order by ckdrelasi"
objCommand.commandText = sql
response.write sql
set aloc = objCommand.execute
if NOT aloc.BOF then
aloc.moveFirst
json = "{ ""cust"" : [ "
body_json = ""
temp = ""
WHILE NOT aloc.EOF
temp = "{"&_
"""ckode"":"""&aloc("ckdrelasi")&""","&_
"""cgrup"":"""&aloc("ckdgruprelasi")&""","&_
"""cnama"":"""&aloc("vnamarelasi")&""""&_
"},"
body_json = body_json&temp
aloc.moveNext
WEND
body_json = mid(body_json,1,len(body_json)-1)
json2 = " ] } "
hasil = json&body_json&json2
response.write hasil
end if
set objCommand = nothing
response.end
%>
这是列表框窗体( 默认. asp) :
<SELECT name="selSelected" id="selSelected" MULTIPLE SIZE="10" class="label" style="width:250px;">
</SELECT>
我不知道问题来自何方。你能告诉我,我的编码有误吗?谢谢。)