AJAX call -
Hier countryid als „AU“ zum Beispiel übergeben wird -Daten von Ajax-Post sind vorbei null an die Steuerung
$("#Countries").change(function() {
var countryId = this.value;
$.ajax({
url: '/Registers/GetStates',
type: "POST",
data: { 'data': countryId },
success: function (states) {
$("#States").html(""); // clear before appending new list
$.each(states, function (i, state) {
$("#States").append(
$('<option></option>').val(state.Id).html(state.Name));
});
}
});
});
Nach der GetStates Aufruf der Methode ‚countryid‘ wird immer als Null in der Steuerung übergeben Methode. Ich bin mir nicht sicher, was ich hier vermisse. Ich versuchte JSON.Stringify ({'data': countryId}) auch. Kann mir jemand helfen?
Controller Action -
[HttpPost]
public SelectList GetStates(string countryId)
{
return Helper.GetStates(countryId);
}