将ActionResult返回到对话框。 ASP.NET MVC
鉴于一种方法..
public ActionResult Method() { // program logic if(condition) { // external library // external library returns an ActionResult } return View(viewname); }
我无法控制外部库的返回类型或方法。 我想抓住它的结果并在页面上的对话框中处理它 – 但我无法弄清楚如何返回页面来执行负责它的jQuery。 有任何想法吗?
您可以通过将jQuery .ajax()
请求路由到它来调用Method()
。 由于它只是直接返回html,请确保将响应类型设置为期望,然后您的jQuery回调处理程序将不得不处理生成的html。 例如,
$("#myButton").click({ $.ajax({ // Basic ajax request properties url: /* route to call Method() */, data: {} dataType: "html", type: "GET", success: function(objResponse){ alert(objResponse); // alerts the html of the result /* Deal with response here, put the html in a dialog */ } }) });
- 如何通过HttpPostedFileBase和ViewModel一起发送上传的文件?
- ASP.NET MVC:如何’模型绑定’非html-helper元素
- 在jQuery AJAX Success Callback中解析JSON List(通过C#)
- 列表通过ASP.Net MVC中的ajax传递
- ASP.NET MVC ActionResult不从ajax请求中读取json数据
- ASP.NET MVC授权属性启动模式?
- 如何发送jQuery $ .get以便Model Binder可以将字符串绑定到参数?
- getJSON回调没有被触发
- url.content(…)喜欢jquery或javascript中的方法?