how to make address fields autocomplete

Hi,

I am trying to make city, state, country autocomplete according to postal code.

i have written a on change JavaScript  but its not work.

i think  the function is not able to call php file.

This my code..please help me

$('#primary_address_postalcode').change(function(){
var pin = $(this).val();

$.ajax({
type:'POST',
url:'SugarCE/SugarCE2/ajaxData.php',
data:'pin='+pin,
dataType: 'json',
success:function(data){

alert(data);

document.getElementById('primary_address_city').value =data[1];
document.getElementById('primary_address_state').value =data[2];
document.getElementById('primary_address_country').value =data[3];
},
error: function(msg)
{
alert(" Error ");
}
});

});

Thank You in Advance

Parents Reply Children
No Data