title: How to access json return values in angular.js action success callback
body: <p>I'm trying to make a post call using resources from angular.js and adding a success and error callback. </p>
  
  <pre><code>wbsModule.factory('gridData', function($resource) {
      //define resource class
      var root = {{ root.pk }};
      var csrf = '{{ csrf_token }}';
      return $resource('{% url getJSON4SlickGrid root.pk %}:wpID', {wpID:'@id'},{
              get: {method:'GET', params:{root : root }, isArray:true},
              update:{method:'POST', headers: {'X-CSRFToken' : csrf }},
        });
  });
  </code></pre>
  
  <p>I'm calling the update action like this:</p>
  
  <pre><code>args.item.$update([], successUpdateCallback, errorUpdateCallback);
  </code></pre>
  
  <p>where I followed this <a href="http://docs.angularjs.org/api/ngResource.%24resource" rel="nofollow">part</a> of the docs:</p>
  
  <pre><code>non-GET instance actions: instance.$action([parameters], [success], [error])
  </code></pre>
  
  <p>The server returns json like this if an error occurs:</p>
  
  <pre><code>jsonReturn = [{'error' : "Oops.. a problem occured. We could not save your last change in the highlighted row: "}]
          jsonReturn.append({'wp_id' : wp_id})
          try:
              for key, value in wpForm.errors.iteritems():
                  jsonReturn.append({"form_errors" : "&lt;br/&gt;" + str(value)})
          except Exception, e:
              print e
          return HttpResponse(json.dumps(jsonReturn, indent=4), mimetype="application/json", status=400)
  </code></pre>
  
  <p>For the error callback I am able access the error messages like this:</p>
  
  <pre><code>     function errorUpdateCallback(result){
              console.log(result.data);
              error = result.data[0].error;
              wp_id = result.data[1].wp_id;
              form_errors = result.data[2].form_errors;
              }
          };
  </code></pre>
  
  <p>But when I try to do the same for the success function I'm getting this error, which is thrown before entering the successUpdateCallback:</p>
  
  <pre><code>'undefined' is not a function (evaluation 'a.push(U(b[c]))')
   http://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js
  </code></pre>
  
  <p>Where I create the json the same as in the error case at the server:</p>
  
  <pre><code>jsonReturn = [{'message' : "Successfull update."}]
  return HttpResponse(json.dumps(jsonReturn, indent=4), mimetype="application/json", status=200)
  </code></pre>
  
  <p>and parsing the success callback the same as the error callback:</p>
  
  <pre><code>        function successUpdateCallback(result){
              console.log("in suc. update");
              console.log(result);
              message = result.data[0].message;
          };
  </code></pre>
  
  <p>Whereas when I return an empty json object I do not get this error and the successUpdateCallback is entered, printing "in suc.update" to the console:</p>
  
  <pre><code>jsonReturn = []
  return HttpResponse(json.dumps(jsonReturn, indent=4), mimetype="application/json", status=200)
  </code></pre>