以下は、[更新]ボタンのクリックで更新を行う私のJavascript関数です。特定のコントローラとアクションでAjaxコールを使用してユーザーをリダイレクトする方法
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) {
}
});
}
そして、私のコントローラ
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 (StoreProcedureContext sc = new StoreProcedureContext())
{
cmd = sc.EditPricing(_xdoc);
}
return View("ManageSubscriptionPlan");
}
それはそのビューに私をリダイレクトしても一部のGoogleをしたと私はJavascript自体にこの事を持っているとOnSuccess
オプションを使用してURLを呼び出すことがわかっていません。私のシナリオでjavascriptを使用してポストバックを行う方法。 また、投稿する前にコードが変更されているため、コードを参照しないでください。私はちょうど更新後に起こるようにリダイレクトしたい。
アヤックスの全体の目的は、同じページに滞在することです、そしてあなたがリダイレクトするときにデータを投稿するAJAXを使用すると、ちょうど無意味であるあなたに感謝@Igor – Steve
。通常の送信を行い、コードを保存してパフォーマンスを向上させます。 –
これはありがたいです! – Steve