Tuesday, 13 February 2018

How to get States,country,cities using ZipCode+javascript


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

How to get the value from web.config(if any value assign as static Key)

Web.Config File:   <appSettings>     <add key="DomainName" value="PW" />     </appSettings> Cl...