Ниже изменения которые нужно внести в код из статьи.
Last active
October 30, 2018 01:09
-
-
Save sanmai/a2431ce9d8dfd54920c90d6dddaf3f62 to your computer and use it in GitHub Desktop.
This file contains 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
jQuery.ajax({ | |
dataType: "json", | |
// https://www.postindexapi.ru/json/199/199151.json | |
url: 'https://www.postindexapi.ru/json/'+postcode.substring(0, 3)+'/'+postcode+'.json', | |
beforeSend: function() { // Уведомим пользователя, что загрузка идёт | |
$("td:last-child p.description.notice, td:last-child p.description.alert", postcode_field.parents("tr")).remove(); | |
$('<p class="description notice loading"></p>').text("Загрузка…").appendTo($("td:last-child", postcode_field.parents("tr"))) | |
}, | |
success: function(data){ | |
postcode_field.val(data.Index); | |
region_field.val(data.Region); | |
area_field.val(data.Area); | |
city_field.val(data.City); | |
if (data.Index != postcode) { | |
var message = "Вы ввели устаревший почтовый индекс: "+postcode+", ваш текущий индекс: "+data.Index; | |
$('<p class="description notice"></p>').text(message).appendTo($("td:last-child", postcode_field.parents("tr"))) | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment