user1290284
user1290284

Reputation: 85

Client side trouble when calling

Please use my previous question as reference. I have marked an answer already.

Question

I'm a .NET developer doing some work for a company that uses Classic ASP. My experience with server side development is VB.NET or C# with some sort of MVC pattern. Consider the following code snippet, I wrote it in an ASP page the company would like to keep and "include" in other pages where this web call would be needed. Kind of like a reusable piece of code. I've left some out for sanity reasons.

//Create ActiveXObject, subscribe to event, and send request
        var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                xmlDoc.loadXML(xmlHttp.responseText);
                debugger;
                var JSON = $.xml2json(xmlDoc);
                parseResponse(JSON);
            }
        }

        urlToSend = encodeURI(REQUEST);
        urlRest += urlToSend
        xmlHttp.open("GET", urlRest, false);
        xmlHttp.send(null);

After struggling with a variety of security problems, I was glad when this finally worked. I changed a setting in Internet Options to allow scripts to access data from other domains. I presented my solution, but the Company would have to change this setting on every machine for my script to work. Not an ideal solution. What can I do to make this run on the server instead of the client's browsers?

I have a little bit of knowledge of the <% %> syntax, but not much.

Upvotes: 1

Views: 565

Answers (1)

Jon P
Jon P

Reputation: 19772

This SO Question should help you call the service server side: Calling REST web services from a classic asp page

To Summarise, use MSXML2.ServerXMLHTTP

Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.open "GET", "Rest_URI", False
HttpReq.send

And check out these articles:

You will also need a way to parse JSON

Upvotes: 2

Related Questions