Files
2023-01-24 20:31:23 +00:00

24 lines
616 B
JavaScript

(function ($) {
$.fn.remoteFill = function (target = false) {
var location = $(this);
let cep = $(this).parent().find('input').val();
cep = String(cep).replace(/[^\d]/g, '');
fetch('/postal/search/' + cep, {
method: 'GET',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'fetch'
}
}).then(function (response) {
let json = response.json();
return json;
}).then(function(json){
target(json)
});
};
})(jQuery);