Error with XMLHttpRequest

Hi, I’m trying to send some parameters via a POST method but I get this error:

ERROR: First argument should be of type System.String
    System.ArgumentException occured.

My code is:

var http = new XMLHttpRequest();
var url = "xxxxxxx";
var params = "param1=xxx&param2=xxx";"POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
    if(http.readyState == 4 && http.status == 200) {

What I’m doing wrong?

params.length is an integer. You need to cast as string from JS:

http.setRequestHeader("Content-length", ""+params.length);