An ASP.NET Web Form using jQuery get() to call Classic ASP

Most of my software development work is numerical and scientific programming, usually in a shell. But every now and then I have to do some Web work. I was looking at the jQuery get() function, which sends an HTTP GET request from the client browser to the Web server, and the fetches the response from the server.


I coded up a little demo program to make sure I understood the get() documentation. My demo was a bit unusual because I was just experimenting. The demo is essentially an ASP.NET Web Form application which contains jQuery code to send a request to a classic ASP script.

To create the demo, I first used Visual Studio to create an “Empty Web Site” as opposed to any other template which gives more than what I wanted. Then I used Notepad to create the ASP.NET demo. Because my annoying blog editor usually messes up anything with less-than or greater-than symbols, here’s an image of the Demo.aspx (and the target classic ASP script).


Before I could run the demo, I needed a target to send the GET request to. I decided to use classic ASP written in VBScript. The Test.asp code looks for a request that has something like x=42 in the query string, peels off the value of x, and returns twice the value.

The whole idea of the exercise was to understand the jQuery.get function. My call to get() is wrapped inside the ready() function so it will execute immediately after the Demo.aspx page loads. The get() call has three parameters. The first is the classic ASP target script. In most cases the target is just a data file. The second parameter is the information to send. In most cases this parameter is left out. I passed two values, x and t, but only x (with value 42) is used. The third parameter is an anonymous callback function that executes when the target returns a response. Here, object ‘theData’ is the return result. I just pasted the result (84) into a div on the Demo page.

This entry was posted in Machine Learning, Miscellaneous. Bookmark the permalink.