Below is my Javascript function which will do update on the click of Update button.
function UpdateData() {
var obj = {
"testData": $("#hdn_EditdsVal").val(),
"feature": $("#hdn_EditdsVal").val()
};
$.ajax({
url: '@(Url.Action("UpdatePlanFeatVal", "SuperAdmin"))',
type: "POST",
dataType: "json",
data: JSON.stringify(obj),
contentType: "application/json",
success: function (result) {
// want to redirect the user using ControllerName/ActionMethod
},
error: function (err) {
}
});
}
And my controller
public ActionResult UpdatePlanFeatVal(string testData,string feature)
{
var cmd = (object)null;
testData = testData.Trim();
string[] words = testData.Split(':');
XDocument _xdoc = new XDocument(new XElement("Pricing"));
foreach (string word in words)
{
if (!string.IsNullOrEmpty(word))
{
string[] wor = word.Split('_');
_xdoc.Root.Add(
new XElement("row",
new XElement("FeatureId", wor[1]),
new XElement("PlanId", wor[2]),
new XElement("Unit", wor[3])
));
}
}
using (StoredProcedureContext sc = new StoredProcedureContext())
{
cmd = sc.EditPricing(_xdoc);
}
return View("ManageSubscriptionPlan");
}
It is not redirecting me to that view and also did some google and found that i have to this thing in Javascript itself and call the url using OnSuccess
option. Any idea how to do postback by using javascript in my scenario.
And also don't go through the code as it is modified before posting. I just want redirect to be happen after update.