我想为 Fill DropDownlist 编写公共函数。并且当程序员要填充 DropDownlist 时调用该方法并设置参数。我写这段代码
function FillDropDownlist(url,dataPas,selector,indexValue,indexText) {
$.ajax({
cache: false,
contentType: 'application/json; charset=utf-8',
url: url,
data:{dataPas},
success: function (data) {
var rows = data.rows;
var drpTransportType = $(selector);
var strOption = '<option value=0>...Select.....</option>';
$(selector+" option").remove();
if (data.rows.length >= 0) {
for (var i = 0, l = rows.length; i < l; i++) {
var ri = rows[i];
strOption += '<option value="' + ri.cell[indexValue] + '">' + ri.cell[indexText] + '</option>';
}
drpTransportType.append(strOption);
}
},
dataType: 'json'
});
}
为了打电话,我写了这段代码
FillDropDownlist("JQGridHandler.ashx", "ActionPage:'TransportType',Action:'FillDrop'", "#Select1", 0, 1);
但这段代码不起作用,并得到错误
Error: FillDropDownlist is not defined
我认为这条线有错误
data:{dataPas},
请帮我完成这个功能,谢谢大家