Hi
I am developing an application where a form has a dropdown for state city and zipcode. On page load i have called jQuery Ajax and bind the DropDownList with json data.
But when edit the page and again i bind the dropdown with another response from json using jQuery Ajax call, but each and every time all the data is binding with html DropDownList.
In Edit mode i want to bind those data which are coming from get api see the below code.
this Ajax call getting one stateid from backend which i want to bind but all data is getting bind. How to solve this issue. Where i am doing wrong.
$.ajax({
type: "POST",
url: '@Url.Action("GetProvider","Provider")',
data: { UserId: personaldetails.UserId, Role: personaldetails.Role, },
success: function (response) {
$.each(response, function () {
$('#firstname').val(response.data.firstName)
$('#middlename').val(response.data.middleName)
$('#lastname').val(response.data.lastName)
$("#datepicker").datepicker("setDate", new Date(response.data.dob));
$('#datepicker').val(response.data.dob)
$('#email').val(response.data.email)
$("#datepickerstartdate").datepicker("setDate", new Date(response.data.dob));
$('#tax').val(response.data.taxID)
$('#ptan').val(response.data.pTan)
$('#npi').val(response.data.npi)
$('#ssn').val(response.data.ssn)
$('#phone').val(response.data.phone)
$('#fax').val(response.data.fax)
$('#adress1').val(response.data.addressLine1)
$('#adress2').val(response.data.addressLine2)
$('#zipcode').val(response.data.zipcode)
$('#website').val(response.data.website)
$('#StateID').val(response.data.stateID);
// $("#StateID").append($("<option></option>").val(response.data.stateID).html(response.data.state));
$("#CityID").append($("<option></option>").val(response.data.cityID).html(response.data.city));
});
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});