I am trying to get the value form api and bind the data to my form.
i have on html table where edit button is there after click on edit button below url open in browser.
http://localhost:5023/Provider/EditProvider?UserId=75747781FF-CE91-4373-8D51-81C16D7E6505&Role=Provider
I want to get the userid data from this url and pass it to my controller from jQuery Ajax.
[HttpPost]
public IActionResult ProviderPersonalDetailsGet([FromBody] ProviderPersonalDetailsParams model)
{
AccountApiCall accountApiCall = new AccountApiCall(Configuration["PrescriptionAPI"]);
var Response = accountApiCall.PostAPIcall<GetProviderMasterModel>(model, "personaldetailsget", HttpContext.Request.Cookies["Token"].ToString());
return Json(Response.data);
}
this is my controller which accept parameter userid and role
currLoc = $(location).attr('href');
if (currLoc.toLocaleLowerCase().indexOf("userid")!=-1)
{
var Roles = 'Provider';
$.ajax({
type: "POST",
url: '@Url.Action("ProviderPersonalDetailsGet","Provider")',
data: types,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
$.each(response, function () {
ddlstate.append($("<option></option>").val(this['id']).html(this['value']));
});
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});