With MVC5, I'm trying to use $.ajax because I need to replace a partial view on a web page. Using @Ajax.ActionLink works except I can't figure out how to retrieve input field values when inside of Razor because the @Ajax.ActionLink was substituted for the form post button. In JavaScript, I can get the input field values, but the $.ajax method doesn't seem to allow "InsertionMode = InsertionMode.Replace" like the @Ajax call does.
My JavaScript looks like this:
$("#Filter_Form").submit(function (event) {
$.ajax({
type: "POST",
url: "UpdateData",
data: { "filter": GetParamsToSend() },
dataType: "text",
//InsertionMode: InsertionMode.Replace, Doesn't work in the jQuery $.ajax
UpdateTargetId: "PersonListDiv"
});
});
var GetParamsToSend = function() {
var f1 = $('input[name=SearchType]:checked').val();
var f2 = "~";
var f3 = $("#FilterEntry").val();
var filter = f1.concat(f2.concat(f3));
return filter;
};
This calls the correct controller method with the correct parameter, but I don't know how to make it replace the partial view that I'm dealing with, which should be replace at the location "PersonListDiv".
Any help on this would be greatly appreciated.