我搜索了网络和stackoverflow,但我找不到任何提示......
我有一个 Grails 2.1.1 项目,我想通过 Ajax 请求从 jQuery 调用控制器函数。到目前为止,我想出了这个:
$.ajax({
type: 'POST',
url: "${createLink(controller:'userSearch',action:'ajaxFindUser')}",
dataType: 'json',
data: {
lastname: $('#searchLastName').val(),
firstname: $('#searchFirstName').val(),
zipcode: $('#searchZipCode').val(),
city: $('#searchCity').val()
},
success: function(data) {
$('#searchSubContainerBody').html(data);
$('#searchTable tr').draggable({
cursor: 'move',
helper: 'clone',
scope: 'drag-guests',
start: function(event, ui) {
searchCloneTableRow.tr = this;
searchCloneTableRow.helper = ui.helper;
searchCloneTableRow.cells = new Array();
$.each(this.cells, function(index, column) {
searchCloneTableRow.cells.push(column.innerText);
});
},
connectWith: '#searchDetailContainerDropArea'
});
$('searchTable').dataTable({
'bJQueryUI':true
});
},
error: function(request, status, error) {
$(errorDialog).html(error);
$(errorDialog).dialog('open');
return false;
},
complete: function() {
//do something
}
});
当我单击按钮触发 Ajax 请求时,DevTools 显示以下错误:
POST > http://localhost:8080/GrailsTest001/authentication/$%7Bg.createLink(controller:'userSearch',action:'ajaxFindUser')%7D 404 (Not Found)
所以,如您所见,URL 获取的 HTML 编码......我怎样才能防止 Grails 对其进行编码?
在Config.groovy
编解码器中设置为none
:
// The default codec used to encode data with ${}
grails.views.default.codec = "none" // none, html, base64
我在这里做错了什么?你能给我任何提示(或更好的:解决方案)吗?任何帮助是极大的赞赏!