自动补全功能

 

引用<script src="autocomplete.js"  type="text/javascript"></script>

    <link href="jquery-ui.css" rel="stylesheet" />

 

function dizixlsj() {
layer.msg("1111");
var khjc = $("#ContentPlaceHolder1_khjc").val();
$.ajax({
type: "POST",
dataType: "json",
async: false,
url: 'ashx/TransportationFeeHandler.ashx',
data: {
ope: "dezhixlsj",
khjc:khjc
},
beforeSend: function () {
//$("#seltable").showLoading();
},
success: function (data) {
var songhuodizi = new Array();
var tihuodizi = new Array();
for (var i = 0; i < data.length; i++) {
tihuodizi[i] = $.trim(data[i].起始地);
songhuodizi[i] = $.trim(data[i].目的地);
}
var songhuodizi = QuChong(songhuodizi);
var tihuodizi = QuChong(tihuodizi);
$("#qsd1").autocomplete({
source: tihuodizi
});
$("#mdd1").autocomplete({
source: songhuodizi
});
//$("#seltable").hideLoading();
}
});
}

//数组去重
function QuChong(Array) {
var res = [];
var json = {};
for (var i = 0; i < Array.length; i++) {
if (!json[Array[i]]) {
res.push(Array[i]);
json[Array[i]] = 1;
}
}
return res;
}

posted @ 2018-04-28 11:34  岳凯歌  阅读(208)  评论(0编辑  收藏  举报