driverdan / node-XMLHttpRequest

XMLHttpRequest for node.js
http://thedanexperiment.com/2009/10/04/emulating-xmlhttprequest-in-node-js/
MIT License
416 stars 299 forks source link

How to use XMLHttpRequest() in c# #118

Open ghost opened 9 years ago

ghost commented 9 years ago

Hello every one,

i have a c# class, when we compile it will generate a javascript code using saltarelle dlls(Saltarelle.jQuery, Saltarelle.Linq, saltarelle.QUnit, Saltarelle.web)

Now i need some code in javascript as shown below

var xmlHttp = new XMLHttpRequest();
var para = "id=testid&name=testname";

        xmlHttp.open("POST", "http://cef", false);
        xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');            
        alert("beforeDone");
        xmlHttp.send(JSON.stringify({ name: "John Rambo", time: "2pm" }));
        alert("almostDone");
        var result = xmlHttp.status;
        if (xmlHttp.readyState == 4) { if (result == 200) { var response = xmlHttp.responseText; alert(response); } }

i have written C# code to auto generate the JS file as below

var xmlHttp = new XMLHttpRequest(); var para = "id=testid&name=testname";

        xmlHttp.open("POST", "http://testdomain", false);
        xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

        xmlHttp.send(para);
        var result = xmlHttp.status;
        if (xmlHttp.readyState == 4)
        {
            if (result == 200)
            {
                var response = xmlHttp.responseText;
            }
        }

While compiling am getting error while creating an object of XMLHttpRequest();

Error 1 The type or namespace name 'XMLHttpRequest' could not be found (are you missing a using directive or an assembly reference?) D:\Views\HostInteraction\HostInteraction.cs