title: What is the Angular JS equivalent of this Curl POST command?
body: <p>I am trying to program the following Curl command using Angular JS. I'm very new to AngularJS, so I may be missing something fundamental.To be specific, this is a mobile app, that is using the ionic framework (which uses Angular JS)</p>
  
  <p>The curl command is this:</p>
  
  <pre><code>curl -X POST  -d "username=xxxx&amp;password=xxxx&amp;action=login&amp;view=console"  http://myserver.com/zm/index.php?skin=xml
  </code></pre>
  
  <p>This works perfectly from command line.</p>
  
  <p>In AngularJS, I have the following code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>angular.module('starter.controllers').controller('MonitorCtrl', function($ionicPlatform, $scope,$http)
  {
              
  console.log("***MAKING REQUEST");
                                                   
  
  //$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
                                                   
   $http({
      url:'http://myserver.com:9898/zm/index.php?skin=xml',
      method:'post',
      headers: {'Content-Type': 'application/x-www-form-urlencoded',
                'Accept': '*/*',
         },
      transformRequest: function(obj) {
         var str = [];
         for(var p in obj)
         str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
         var foo= str.join("&amp;");
         console.log ("****RETURNING "+foo);
         return foo;
      },
         data: {username:'admin',
                password:'xxxx',
                action:'login',
                view:'console'}
         
    })
                                                   
  .success (function()
  {console.log("****YAY");
  })
  .error(function(data, status, headers, config)
  {
          console.log("***OOPS "+status + " H: "+data);
  });
                                                   
                                                  
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>When I run this code, I see a POST  request going to my server (I am sniffing using httpry) and a 200OK being returned from the server with the required payload, but my success handler is not being called. The error handler is called with a status of 0        </p>