This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var address = new Bloodhound({ | |
| datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), | |
| queryTokenizer: Bloodhound.tokenizers.whitespace, | |
| remote :{ | |
| url: 'https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address/', | |
| replace: function(url,q){ | |
| this.ajax.data = '{ "query": "' + q + '" }'; | |
| return url + '?q=' + q; | |
| }, | |
| filter: function(resp){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var API_KEY = "ВАШ_API_КЛЮЧ"; | |
| function suggest(resource, query) { | |
| var http = new ActiveXObject("MSXML2.XMLHTTP"); | |
| http.open("POST", "http://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/" + resource, false); | |
| http.setRequestHeader("Content-Type", "application/json"); | |
| http.setRequestHeader("Authorization", "Token " + API_KEY); | |
| var data = "{ \"query\": \"" + query + "\" }"; | |
| http.send(data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dim http | |
| Set http = CreateObject("WinHttp.WinHttpRequest.5.1") | |
| timeout = 2000 'milliseconds | |
| http.SetTimeouts timeout, timeout, timeout, timeout | |
| query = "7719402047" | |
| request = "{ ""query"": """ & query & """ } " | |
| http.Open "POST", "https://suggestions.dadata.ru/suggestions/api/4_1/rs/findById/party" | |
| http.SetRequestHeader "Content-Type", "application/json" |
Справочник переехал: https://github.com/hflabs/region
Для большинства PHP-приложений достаточно использовать jQuery-плагин. Он проще в подключении и красиво выглядит. Используйте прямую работу с API на PHP только в том случае, если вы твёрдо уверены, что jQuery-плагин не подходит.
-
Внизу файла
cart.tplдобавляем:{literal} <link href="https://cdn.jsdelivr.net/npm/suggestions-jquery@latest/dist/css/suggestions.min.css" rel="stylesheet" /> <script src="https://cdn.jsdelivr.net/npm/suggestions-jquery@latest/dist/js/jquery.suggestions.min.js"></script>
<script>
NewerOlder