This ajax works fine but the controller does not return the view. It returns either blank view or returns inappropriate View. How can I solve this issue.
Getprojectsbylocation(int state_id) { var ds = _dal.Getprojectsbylocation(state_id); var dt = ds.Tables[0]; List<Projects> li = new List<Projects>(); li = Helper.ConvertDataTable<Projects>(dt); return View(); }
My controller code:
public IActionResult Getprojectsbylocation(int state_id) { var ds = _dal.Getprojectsbylocation(state_id); var dt = ds.Tables[0]; List<Projects> li = new List<Projects>(); li = Helper.ConvertDataTable<Projects>(dt); return View(); }
Ajax call:
$('#button').click(function () { $.ajax({ url: "/Company/Getprojectsbylocation", type: "get", dataType: "application/ json; charset = utf-8", data: { state_id: $("#txtstateId").val() } }) });