ajax - 基本 URL 在 Grails 生产模式下不起作用
问题描述
我正在使用 grails-2.4.5 版本。我的侧面菜单模板中有一些菜单链接,我在其中使用控制器名称和操作的属性。
在我的 application.js 文件中使用该属性调用 URL。它在开发模式下工作正常,并且可以正常显示每一页。但是当我运行战争时,如果我单击链接,它只会在 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();
});
})
解决方案
推荐阅读
- d - 如何覆盖默认结构构造函数
- selenium - 为什么 Selenium webdriver 没有打开网页?
- swift - 无法将类型“()”的返回表达式转换为返回类型“T”
- html - 如果单词内容增加,如何到达p标签的下一行
- ios - SwiftUI 中的平面导航最佳实践
- sql - T-SQL:执行批处理时出错。错误消息是:从 MyTable 中选择 * 的算术溢出
- java - 无法使用 Microsoft SQL Server 和 Javax.Persistence 解析 Java 中的列 [名称]
- java - Failsafe 插件在 CI 上随机崩溃
- python - 根据不同的列名加入两个 dfs?
- typescript - 为什么'let'声明符号将转换为 TypeScript 中的字符串索引签名?