【问题标题】:mvc 4, How to open (new page) HttpPost view controller? with model datamvc 4、如何打开(新页面)HttpPost 视图控制器?有模型数据
【发布时间】:2016-04-11 00:57:06
【问题描述】:

这是我的控制器

[HttpPost]
public ActionResult Administracion(Usuario usuario)
{
    var tupla = new Tuple<Usuario>(usuario) { };
    return View(tupla);

}

现在在 Jquery 我有 Usuario 对象, 我只想调用(不更改 httpget)到控制器中的 Administracion 函数以返回视图。

这类似于执行 @Html.ActionLink 但带有 httpost 和模型数据

那我想要什么? 只需使用 jquery 加载带有模型的 httpost 类型的新“页面/视图”

它需要使用 jquery(我有 Usuario 对象)

【问题讨论】:

  • 你的模态对话框有什么库?

标签: jquery ajax asp.net-mvc asp.net-mvc-4


【解决方案1】:

尝试使用ajax

$.ajax({
    type: "POST",
            url: "../yourController/Administracion",
            dataType: "text",
            data:  {Usuario : data},
   success: function(result){
        // replace your return data on div
   },
 error: function(xhr){
        alert('Request Status: ' + xhr.status + ' Status Text: ' + xhr.statusText + ' ' + xhr.responseText);
    }
 });

【讨论】:

  • 但是,页面不会在新的(url)页面中,如果在执行之前 ajax 在 www.mypage.com/usuario 中,这将继续使用相同的 url 页面 por 示例/login 并执行ajax,UI会改变,但页面链接不会,不是吗?
  • 是的……试试这个stackoverflow.com/questions/8148632/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-02-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-24
  • 2021-07-21
  • 1970-01-01
相关资源
最近更新 更多