My code snippet is:
$('#PostCode').autocomplete({
source: function (request, response) {
$.ajax({
url: "${createLink(controller:'postcode',action:'getValidPostcodeValues')}",
dataType: "json",
success: function( data ) {
response( $.map( data, function( item ) {
return {
id: item.id,
value: item.name
}
}));
}
});
},
minLength: 1,
select: function (event, ui) {
$('#PostCodeHidden').val(ui.item.id);
}
});
However it doesn't work. I use chrome web tools to track the ajax call url is something like
GET http://localhost:8080/edp-grails/xxx/xxx/$%7BcreateLink(controller:'postcode',action:'getValidPostcodeValues')%7D 404 (Not Found)
Why grails can't interpret the createlink to the actual url?