js实现输入框自动提示功能

$("#titleInput").keyup(function(){             	 		  	  
				$("#titleInput").autocomplete({			
				    source:	GetReturnValue()	  			
				});					
		});

function GetReturnValue() {  
	           var result = "";  
	           $.ajax({  
	               type: "POST",  
	               url: "url",  
	               data: "keyword="+$("#titleInput").val(),  	               
	               dataType: "json",  
	               async: false,//同步  
	               success: function (data) { 	 	               		                	   						  
			              result = eval( data.title);				              	               			              		                   				               	   
	               }, error: function () {  	               		               	
	                   result = "err";  
	                   alert("err result:"+result);	                  
	               }  
	           })  	          
	           return result;	          	           
   }

你可能感兴趣的:(javascript)