I have following ajax call which I used to call the controller method.
我跟随ajax调用,我曾经称之为控制器方法。
self.ajax = function (url, postData, callBack, callBackParam) {
$.ajax({
url: url,
type: "GET",
data: postData,
success: function (data) {
},
error: function () {
alert();
},
});
}
When I execute it, Its working fine and this goes to the relevant url that I mentioned in the function. Following is my controller method.
当我执行它时,它的工作正常,这将转到我在函数中提到的相关URL。以下是我的控制器方法。
public ActionResult Details()
{
return View();
}
In this controller I am calling a separate view. What I want is to open the new page by using this view. Is it possible in this scenario?
在这个控制器中,我调用一个单独的视图。我想要的是使用此视图打开新页面。在这种情况下是否可能?
Because in here final ajax response is comes to the success code so I dont see any way to open this as separate page.
因为在这里最终ajax响应是成功代码所以我没有看到任何方式打开这个单独的页面。
Thanks.
1 个解决方案
#1
0
If I got you right,
如果我找对你,
You will be having a Controller method, to which you call 'GET' with essential parameters
您将拥有一个Controller方法,您可以使用必要参数调用'GET'
public ActionResult PostMethod(YourModel Object)
{
return Json(true);
}
And another method which return view
还有另一种返回视图的方法
public ActionResult Details()
{
return View();
}
So In your ajax call, You will be calling PostMethod
to which you are passing the parameter, and on its success, the page Details
will be opened in a new window.
所以在你的ajax调用中,你将调用传递参数的PostMethod,并且在成功的情况下,页面Details将在新窗口中打开。
self.ajax = function (url, postData, callBack, callBackParam) {
$.ajax({
url: url,
type: "GET",
data: postData,
success: function (data) {
if(data){
window.open("url of Details View", "_blank"); // site.com/controller/Details
}
},
error: function () {
alert();
},
});
}
#1
0
If I got you right,
如果我找对你,
You will be having a Controller method, to which you call 'GET' with essential parameters
您将拥有一个Controller方法,您可以使用必要参数调用'GET'
public ActionResult PostMethod(YourModel Object)
{
return Json(true);
}
And another method which return view
还有另一种返回视图的方法
public ActionResult Details()
{
return View();
}
So In your ajax call, You will be calling PostMethod
to which you are passing the parameter, and on its success, the page Details
will be opened in a new window.
所以在你的ajax调用中,你将调用传递参数的PostMethod,并且在成功的情况下,页面Details将在新窗口中打开。
self.ajax = function (url, postData, callBack, callBackParam) {
$.ajax({
url: url,
type: "GET",
data: postData,
success: function (data) {
if(data){
window.open("url of Details View", "_blank"); // site.com/controller/Details
}
},
error: function () {
alert();
},
});
}