MVC4和jquery:使用按钮重定向到另一个视图,并且还将参数对象发送到另一个视图 - c#

首先,我必须说我是MVC4的新手,并且同时学习和开发此应用程序。
在此应用程序中,有一个“ index.cshtml”视图,其中包含“新鲜”跨度(按钮)。
单击此按钮后,我想要:

重定向到另一个名为“ Interview”的视图,
也想发送参数“数据”到视图(Controller Action方法)

Index.cshtml查看代码段:

.
.
some code
<span class="action-class" id="fresh">Start Fresh Interview</span>
.
.
some code
.
.
$("#fresh").click(function (e) {
            var tech;
            var guid = '@Model.currentInterviewDetails.GuId';
             $.ajax(
            {
                type: "post",
                url: '@Url.Action("Interview","Home")',

                data: {
                    GuId: guid,
                    IntervieweeName: $("#IntervieweName").val(),
                    LevelId: $("#SelectedLevelId").val(),
                    DId: $("#SelectedDesignationId").val(),
                    TrackId: $("#SelectedTrackId").val(),
                    TechId: tech
                },

                success: function (data) {

                }
            });
         });

但是没有加载新视图(即“ views.cshtml”),我可以看到旧视图(“ index.cshtml”)

Interview.cshtml代码段:

@model InterviewAssistant.Models.CommonWrapper
@{
    ViewBag.Title = "Interview";
}
@
@if (Model.tech != null && Model.tech.Count() > 0)
{
@Html.HiddenFor(m => m.SelectedTrackId)
     @Html.DropDownListFor(
            m => m.SelectedTechId,
            new SelectList(Model.tech, "TechId", "TechName"),
            string.Empty
            )
}

下面是控制器代码:

public ActionResult Interview(InterviewDetailsModel interview)
        {

            string name = System.Web.HttpContext.Current.User.Identity.Name;

            CommonWrapper wrapper = new CommonWrapper();
            wrapper.track = CommonWrapper.GetTracks();
            wrapper.level = CommonWrapper.GetLevel();
            wrapper.designation = CommonWrapper.GetDesignation();
            wrapper.currentInterviewDetails = interview;

            wrapper.tech = (from s in CommonWrapper.GetTechnology()
                            where s.TrackId == interview.TrackId
                            orderby s.TechName
                            select s).ToList();


            return View("Interview", wrapper);

        }

有人可以帮我解决这个问题吗?

提前致谢 :-)

参考方案

您可以通过简单的方法制作Controller

 public class DefaultController : Controller
{
   Public ActionResult Index()
   {
      Model model = new Model();
      model.TechId = "TechId here";
      model.TechName = "TechName";

      return View(model);
   }

    public ActionResult InterView()
     {
         return View();
     }

    [HttpPost]
    public ActionResult InterView(Model model)
    {
       //retrive model here 

       //return your interview view here
       return View("InterView");
    }
}

在Index.cshtml视图中:

@model namespace.model.modelname 

@using (Html.BeginForm("InterView", "Default", FormMethod.Post))
{
    <input type="submit" name="SubmitInterview" value="Submit" />
}

当回复有时是一个对象有时是一个数组时,如何在使用改造时解析JSON回复? - java

我正在使用Retrofit来获取JSON答复。这是我实施的一部分-@GET("/api/report/list") Observable<Bills> listBill(@Query("employee_id") String employeeID); 而条例草案类是-public static class…

改造正在返回一个空的响应主体 - java

我正在尝试使用Retrofit和Gson解析一些JSON。但是,我得到的响应机构是空的。当我尝试从对象中打印信息时,出现NullPointerException。我确保URL正确,并且我也确保POJO也正确。我正在使用jsonschema2pojo来帮助创建POJO类。这是我要解析的JSON{ "?xml": { "@versi…

每个文件合并后添加换行 - python

我有很多类似以下内容的JSON文件:例如。1.json{"name": "one", "description": "testDescription...", "comment": ""} test.json{"name"…

Json到php,json_decode返回NULL - php

我正在用PHP进行JSON解析器的一些API,用于存储有关遗产的信息。我在解析时遇到问题,因为它返回的是NULL值而不是数组或对象。简单的JSON代码可以很好地解析,但是可以这样:{"success":true,"totalCount":1,"data":[{"id":99694…

将ajax的值存储到javascript变量中 - javascript

我有一个php文件,其中我从服务器获取数据。该php文件的输出是一个包含json格式数据的变量。PHP文件:<?php $dbHostName = "localhost"; $dbUserName = "venseld"; $dbUserPass = "wecuuu"; $dbName = &…