title: Grails remoteLink
body: <p>I'm trying to make a call to the server with Ajax using Grails remoteLink. The code is the following:</p>
  
  <pre><code>&lt;g:remoteLink controller="event" action="recommend" id="1" onSuccess="recommend(e)" params="[artist:searchedArtist]"&gt;
     Recommend
  &lt;/g:remoteLink&gt;
  </code></pre>
  
  <p>The controller is:</p>
  
  <pre><code> def recommend = {  
                  .
                  .
                  .
     def jsonList = [artist: "${params.artist}",
             location: [
                  lat:"53.872715",
                  lng:"-1.372895"]
             ]
  
     render jsonList as JSON
  }
  </code></pre>
  
  <p>and the javascript function is:</p>
  
  <pre><code>function recommend(response){
     var recommendedResults = eval('(' + response.responseText + ')');
  
     var point = new google.maps.LatLng(${recommendedResults.location.lat}, ${recommendedResults.location.lng});
     var myMarkerOptions = {
           position: point, 
           map: map
         };
     var marker = new google.maps.Marker(myMarkerOptions);    
  }
  </code></pre>
  
  <p>My problem is that the recommend() javascript function is never being called.
  Any thoughts? Thanks very much.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I just noticed that the line:</p>
  
  <pre><code>var point = new google.maps.LatLng(${recommendedResults.location.lat}, ${recommendedResults.location.lng});
  </code></pre>
  
  <p>was not right. So just for debugging purposes, I tried with the "recommend()" javascript function like this:</p>
  
  <pre><code>function recommend(response){
      alert.window("Foo");
  
    }
  </code></pre>
  
  <p>and still doesn't work. The alert never pops up.</p>
  
  <p>The code fragment of the remoteLink which appears in the html source is:</p>
  
  <pre><code>&lt;a href="/Ontourtest/event/recommend/1?artist=deftones" onclick="new Ajax.Request('/Ontourtest/event/recommend/1',{asynchronous:true,evalScripts:true,onSuccess:function(e){recommend(e)},parameters:'artist=deftones'});return false;"&gt;Recommend&lt;/a&gt;
  </code></pre>