我有以下Ajax.actionlink,它将是action方法并返回一个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");
}
}
}
答案 0 :(得分:0)
当您返回数据时,要合并html字符串。
<a href="xxx">test</a>
到UpdataTargetId:startprocess。
当你返回json进行查看时,然后执行“Animate”功能。 所以,你可以在Animate中构建链接。
function Animate(result)
{
$(result).each(function(index, item){
// todo construct the link
});
}