hi i have an Invalid constructor invocation but all is correct
ps. here is the xmlhttprequest class:
var xhr = new XmlHttpRequest();
xhr.OnLoadFinish = function() {
Console.Info(xhr.ResponseText);
};
xhr.Open("GET", "http://www.google.de/");
xhr.Send(null);
what is wrong?ps. here is the xmlhttprequest class:
public class XmlHttpRequest
{
public XmlHttpRequest()
{
}
public dynamic OnLoadFinish;
public dynamic OnSendFinish;
public string MimeType { get { return _webrequest.MediaType; } set { _webrequest.MediaType = value; } }
public object ResponseText { get; set; }
private HttpWebRequest _webrequest;
public void Open(string method, string url)
{
_webrequest = (HttpWebRequest) WebRequest.Create(url);
_webrequest.Method = method;
}
public void Send(object data)
{
if(data == null)
{
var resp = (HttpWebResponse)_webrequest.GetResponse();
using (var s = resp.GetResponseStream())
{
ResponseText = new StreamReader(s).ReadToEnd();
if (OnLoadFinish != null) OnLoadFinish();
}
}
else
{
using (var s = _webrequest.GetRequestStream())
{
var sw = new StreamWriter(s);
sw.Write(data);
sw.Flush();
if(OnSendFinish != null) OnSendFinish();
}
}
}
}