使用jQuery的autocomplete实现联想查询

jquery-3.2.1.min.js 、jquery-ui.min.js 、jquery-ui.css

 $("#dwmc").autocomplete({
      source: function( request, response ) {
        var dwmcCode1 = $("#dwmcCodeArg").val();
        var ishzyx = $("#ishzyx").val();
       //if(ishzyx && ishzyx.indexOf("否")==-1 && dwmcCode1 && dwmcCode1.indexOf("其它")==-1 ){
       if( dwmcCode1 && dwmcCode1.indexOf("其它")==-1 ){
         var term = request.term;
         $.ajax({
                        url:  rootPath+"/sign/toSignSearch.html?time="+new Date().getTime()+"&searchParam="+encodeURI(encodeURI(term))+"&searchParamType="+encodeURI(encodeURI(dwmcCode1)),
                        dataType: "json",
                        success: function( data ) {
                           response( $.map( data, function( item ) {
                                return {
                                    value: item.name
                            }
                            }));
                        }
                })
          }      
        },
       minLength: 1,
       select: function( event, ui ) {
         $("#dwmc").val(ui.item.value);
       }
    });

 

转载于:https://www.cnblogs.com/yang1018/p/10838685.html

你可能感兴趣的:(使用jQuery的autocomplete实现联想查询)