Я использую jQuery метод автозаполнения, я получил значение страны из файла localhost json. но не удалось назначить автозаполнение внутри метода поиска, а также назначить глобальную переменную.
КОД ЗДЕСЬ:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DevBridge Autocomplete Demo</title>
<link href="content/styles.css" rel="stylesheet" />
</head>
<body>
<div class="container">
<h2>Ajax Lookup</h2>
<p>Type country name in english</p>
<div style="position: relative; height: 80px;">
<input type="text" name="country" id="autocomplete" style="position: absolute; z-index: 2; background: transparent;"/>
<input type="text" name="country" id="autocomplete" disabled="disabled" style="color: #CCC; position: absolute; background: transparent; z-index: 1;"/>
</div>
<script type="text/javascript" src="scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery.mockjax.js"></script>
<script type="text/javascript" src="src/jquery.autocomplete.js"></script>
<script type="text/javascript" src="scripts/countries.js"></script>
<script type="text/javascript">
$("document").ready(function(){
$.ajax({
type: 'POST',
url: 'http://localhost/json-autocomplete/auto.json',
success: function(callback) {
for(i=0;i<=callback.RestResponse.result.length;i++){
test(callback.RestResponse.result[i].country);
}
},
});
});
$('#autocomplete').autocomplete({
lookup: test,
onSelect: function (suggestion) {
console.log(suggestion);
}
});
</script>
</body>
</html>