基本网址在grails生产模式下不起作用

时间:2019-03-26 14:31:04

标签: ajax grails grails-2.0

我正在使用grails-2.4.5版本。我的侧面菜单模板中有一些菜单链接,我在其中使用属性来表示控制器名称和操作。 在我的application.js文件中,调用带有该属性的URL。在开发模式下可以正常工作,并且可以正常显示每个页面。但 进行战争时,如果单击链接,则仅在网址中附加#号,而不显示任何页面。谁能帮我提供我的代码。我的 代码如下:

我的菜单链接>>

...
<li>
    <a class="action-item" controller="designation" action="index" href="#"><i class="fa fa-briefcase fa-fw"></i> Designation</a>
</li>
...

我的js函数呈现页面>>

    $(document).ready(function () {
    $("a.action-item").on("click", function (e) {
        var controller = $(this).attr("controller");
        var action = $(this).attr("action");
        var baseUrl = "http://localhost:8090/madrasa/";

        $("#spinnerDiv").show();
        $.ajax({
            url: baseUrl + controller + "/" + action,
            data: {
            },
            type: "GET",
            dataType: "html",
            success: function (data) {
                $('#page-wrapper').html(data);
                $("#spinnerDiv").hide();
            },
            error: function (xhr, status) {
                if (xhr.status == 403) {
                    showForbiddenModal("Sorry, You are not authorized for this action");
                    $("#spinnerDiv").hide();
                    return false;
                }
                console.log("Sorry, there was a problem!");
            },
            complete: function (xhr, status) {
                $("#spinnerDiv").hide();
            }
        });
        e.preventDefault();
    });
})

0 个答案:

没有答案
相关问题