我制作了一个 javascript 来制作列表框的值列表。这些值来自SQL Server
. 当我对数据库上的值进行一些更改时,我的列表框中的值不会更新。似乎浏览器缓存了值什么的,因为当我清除浏览器上的缓存时,列表框中的值会更新。
这是我的javascript(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
%>
这是列表框形式(default.asp):
<SELECT name="selSelected" id="selSelected" MULTIPLE SIZE="10" class="label" style="width:250px;">
</SELECT>
我不知道问题出在哪里。你能告诉我我的编码有没有错误?谢谢 :)