views:

914

answers:

1
A: 

So i figured it out, It had to do with conflicting content types

make sure you set it as
Content-Type = application/x-www-form-urlencoded;

var DRUPAL_JSON_URL = "http://myDrupalsSite.com/services/json";

var req;
DrupalService.prototype.request = function(dataObject, callback){
    var url = DRUPAL_JSON_URL;

    req = false;


    var params = "method=system.connect"; 

    try {
     req = new XMLHttpRequest();
    } catch(e) {
     req = false;
    }

    if(req) {
     req.onreadystatechange = function() {//Call a function when the state changes.
      if(req.readyState == 4 && req.status == 200) {
       alert("test " + req.responseText)
       console.log("RESPONSE "+req.responseText);

      }
     }
     req.open("POST", url, true);
        req.setRequestHeader("Content-length", params.length);
     req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     req.send(params);
    }
}
abritez