0

我有以下 Ajax.actionlink,它将执行操作方法并返回 JSON:-

@Ajax.ActionLink("Start Process", "StartProcess", "Home",
new { name = "BuisnessProcess" },
new AjaxOptions 
    {   HttpMethod = "POST",
        LoadingElementId = "tobehide2",
        UpdateTargetId = "startprocess",
        OnSuccess = "Animate" }) 
</div> <img id="tobehide2" src="~/Content/ajax-loading2.gif" />

目前,当用户单击链接时,它将在浏览器中显示 JSON 信息:-

{"activityId":"2119_666_BuisnessProcess_process1_setverialbe","processId":"666_BuisnessProcess_process1"}

但我想做的是基于返回的 Json 构建另一个 Ajax.actionlink,并将其activityId作为新参数传递给 Ajax.actionlink。

此致

:::更新:::

[HttpPost]
public ActionResult StartProcess(string name)
{
    using (var client = new WebClient())
    {

        try
        {
            var query = HttpUtility.ParseQueryString(string.Empty);
            query["j_username"] = "kermit";
            query["hash"] = "9449B5ABCFA9AFDA36B801351ED3DF66";
            query["loginAs"] = User.Identity.Name;
            query["imagurl"] = "123";

            var url = new UriBuilder("http://localhost:8080/jw/web/json/workflow/process/start/" + name.ToString() + ":28:process1");

            url.Query = query.ToString();
            string json = client.DownloadString(url.ToString());

            Thread.Sleep(500);

            return Content("Process started succsfully. Returned values are :-" + json);
        }
        catch (System.Net.WebException ex)
        {

            return Content("", "application/json");
        }
    }
}
4

1 回答 1

0

当您在操作中返回数据时,要组合 html 字符串。

<a href="xxx">test</a>

到 UpdataTargetId :启动进程。


当您返回 json 以查看时,然后执行“动画”功能。因此,您可以在 Animate 中构建链接。

function Animate(result)
{
    $(result).each(function(index, item){
        // todo construct the link
    });
}
于 2012-10-22T10:34:59.620 回答