1)you can use this api--https://api.zippopotam.us/us/
you can write the below code in any fucntion
function test()
{
var zip=90210;
$.getJSON({
url : 'https://api.zippopotam.us/us/'+zip+'',
data : {
sensor : false
},
success : function( data, textStatus ) {
debugger;
city =data.places[0].state
state =data.places["0"]["place name"]
country =data.country
//pre-fill the city and state
$('input[title="City"]').val(city);---//city textbox ID
$('input[title="State Required Field"]').val(state);----//state textbox ID
$('input[title="Country Required Field"]').val(country);----////country textbox ID
}
});
});
}
No comments:
Post a Comment