title: AJAX post JSON data from Javascript to Grails
body: <p>I'm trying to POST JSON formatted data from Javascript (using Prototype) to Grails. My Javascript code is:</p>
  
  <pre><code>var JSONObject = new Object;
      JSONObject.id = "23";
      JSONObject.name = "Test 1";
      JSONstring = JSON.stringify(JSONObject);
  
  
  
   var url = "${createLink(controller:'testController', action:'receiveJson')}";
      new Ajax.Request(url, {
        method:'post',
        contentType:'application/json',
        parameters:JSONstring,
        asynchronous:true,
        onSuccess: function (req) {
          sendInfoResponse(req.responseText);
        }
      });
  </code></pre>
  
  <p>and the code in my Grails controller is:</p>
  
  <pre><code>def receiveJson = {
    def json = request.JSON;
  }
  </code></pre>
  
  <p>However, the 'json' variable appears to be empty in my tests. I'd be so grateful if someone could explain what I'm doing wrong. Many thanks.</p>