title: AngularJS, POST and GET XMLdata
body: <p>simple question, how would I write this in javascript/AngularJS.. this pythonscript works:</p>
  
  <pre><code>xml = &lt;data&gt;&lt;user&gt;blabla&lt;/user&gt; ..... etc
  url = 'http://localhost:3080'
  response = urllib2.urlopen(url, xml)
  print response
  </code></pre>
  
  <p>Long story:
  I'm playing around with an old, legacy XML service and thought it could be fun to get something working with AngularJS. I might confess that I'm not that familiar with either Angular or Javascript, please bear with me.</p>
  
  <p>The XMLservice expects files with data and instructions on what functions to run etc. It will then respond with another xml file with the answer. However, I can't get the simplest function (login) to work at all.</p>
  
  <p>If I try a "GET" and play with params, the service is triggered but logs "invalid" since it's either missing the XML data or the Xmldata is messed up (when added as param)</p>
  
  <pre><code>angular.module('myApp.loginServices', []).
  factory('LoginSource', ['$http',function($http){
  
     return {
         get: function(url, callback, transform){
              $http.get(
                  url,
                  {transformResponse:transform}).
  
              success(function(data, status) {
                  console.log("success!!!!!!" + status+ " data");
                  callback(data);
              }).error(function(data, status) {
                  console.log("FAILED!!!! " + status);
              });
  </code></pre>
  
  <p>So I try a POST, like this, and this one gives me "status 0" and XmlService logs "501", maybe my xml is messed up or something, but it looks like it's not even reaching the service according to the logs?</p>
  
  <pre><code>    factory('LoginSource', ['$http',function($http){
  
         return {
         get: function(url, callback, transform, xmlData){ 
             console.log('xmlData: ' +xmlData);
         $http({
          url: url,
          method: "POST",
          data: xmlData,
          headers: {'Content-Type': 'application/x-www-rform-urlencoded'}
      }).success(function (data, status, headers, config) {
              callback(data);
  
          }).error(function (data, status, headers, config) {
              console.log('status: ' +status);
          }); 
  
         }
          };
  </code></pre>
  
  <p>I guess it's me being too much of a rookie with javascript and angularJs.. any help appreciated</p>