我有一个带有 jQuery Click 的 View 。我想将 ID 发送到 Controller 并打开 View 。
j("#jstree_demo_div").on('select_node.jstree', function (e, data) {
console.log(data.node.a_attr.href); // Node value
$.ajax({
type: "GET",
url: '@Url.Action("FilterCategories", "FileUploads")',
dataType: "html",
success: function (data) {
/* alert(data); */
},
statusCode: {
404: function (content) { alert('cannot find resource' + data.node.a_attr.href); },
500: function (content) { alert('internal server error' + data.node.a_attr.href); }
},
error: function (req, status, errorObj) {
// handle status === "timeout"
// handle other errors
}
});
});
如果取消注释 alert(data);
,我可以在警报中看到该页面,但是如何打开我的 Controller 并返回我的 View ?
我的 Controller
public ActionResult CategoryId(/*int? CategoryId*/)
{
//Something with CategoryId
return View();
}
我在 Views 文件夹中有一个 View CategoryId。我想我需要更多关于成功:函数(数据)
最佳答案
我今天早些时候做了类似的事情,发现这确实有效:
success: function(response){
document.write(response);
}
关于javascript - 通过 jQuery Controller 打开另一个 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30704508/