I created a cascade dropdown using jQuery Ajax and ASP.Net MVC I have set my ajax request OnChange of dropdown here is my code:
@Html.DropDownList("Agency_Id", null, htmlAttributes: new { @class = "form-control", @onchange = "bring_projects(this.value,'bring_projects_by_agency','Project_Id')" })
The projects DropDown:
@Html.DropDownList("Project_Id", null, htmlAttributes: new { @class="form-control"})
here is my script:
function bring_projects(id, funcs, divname) {
var ajax_image = "<img src='./Content/loading.GIF' >";
$('#' + divname).html(ajax_image);
var params = "&agency_id=" + id;
$.ajax({
url: funcs,
type: "POST",
data: params,
})
.done(function (r) {
$('#' + divname).html(r);
});
}
it gives the following error:
Server Error in '/' Application.
The required anti-forgery form field "__RequestVerificationToken" is not present.
Note: I am not Submiting the form I Just do ajax request OnChange of DropDown in my Edit page.