Hello,
I have a form created with ASP.NET MVC.
I have field like "Address 1 / Address 2/ Country/ Zip Code/ City.
When entering text in address field 1, it will be necessary to do an autocomplete according to the list returned by the API and by selecting an element, it allows me to fill in the other fields mentioned above.
JSON IN API, i pass the code country and the address entered
{
"address": "20 avenue",
"country": "BE"
}
JSON OUT
{
"error": 0,
"error_desc": null,
"location_list": [
{
"address": "AVENUE DE L HELIPORT 20",
"postcode": "1000",
"city": "BRUXELLES",
"country": "BE"
},
{
"address": "AVENUE DES ARTS 20",
"postcode": "1000",
"city": "BRUXELLES",
"country": "BE"
},
{
"address": "RUE DU PONT DE L AVENUE 20",
"postcode": "1000",
"city": "BRUXELLES",
"country": "BE"
},
{
"address": "AVENUE LEGRAND 20",
"postcode": "1000",
"city": "BRUXELLES",
"country": "BE"
},
{
"address": "AVENUE LIVINGSTONE 20",
"postcode": "1000",
"city": "BRUXELLES",
"country": "BE"
}
]
}
I want to display informations into location_list !!
<div class="group-input has-feedback has-feedback-left">
<input type="text" oninput="allCaps(this)" class="js-addr js-addr-line1 form-control input-addr input-lg"
autocomplete="chrome-off" id="address1" required="required" ></div>
$('#address1').autocomplete({
source: function (request, response) {
var req = {
address: $("#address1").val(),
country: $("#addr-country-code").val()
};
$.ajax({
type: 'POST',
dataType: 'json',
url: glbBaseUrl + "/search_address",
data: req,
success: function (result) {
console.log("RES => ", result );
var test = $.map(resp, function (obj) {
});
},
error: function (resultat, statut, erreur) {
console.log(resultat, statut, erreur);
}
});
}
});
[HttpPost]
public clsSearchaddressResponse search_address(clsSearchaddressRequest req)
{
req.address = req.address;
req.country = req.country;
return _cprWS.search_address(req);
}