javascript - 通过 jQuery Controller 打开另一个 View ?

标签 javascript jquery asp.net-mvc-4

我有一个带有 jQ​​uery 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/

相关文章:

javascript - 如何在类声明上实现伪经典继承?

asp.net-mvc-4 - 与 MVC 并排运行 ServiceStack

asp.net - 如何在 html 菜单中使用箭头标记而不是元素符号

asp.net-mvc-4 - 错误 : Cannot convert lambda expression to type 'string' because it is not a delegate type

javascript - 如何使用jQuery来选择具有唯一文本内容的XML节点?

javascript - 这是将 html 转换为文本的安全方法吗

javascript - 使用javascript将子菜单添加到垂直菜单

jquery - 在jquery中使用图像作为按钮,具有点击效果

javascript - 淡入附加元素

javascript - .id() 方法在 jQuery 选择器上失败