Cyphos wrote:
I'm just learning how to use the XmlHttpRequest object. Very cool.
However, I'm wondering how I can call a specific server-side method.
You cannot do that directly.
For example, say I have a method defined as follows on an ASP.NET
code-behind file
public string GetServerTime()
{
return DateTime.Now.ToShortTimeShort();
}
Would I have to change the request method to POST? Could someone post
an example please? Or can I simply not call a method, and have to call
the method from the Page_Load event?
Either question has to be answered with: You have not yet understood how
XMLHTTPRequest works. Here it is in short: it sends a request to a host
which is running a HTTP server, returns information about the request
status and the server reply. Nothing more, nothing less.
So if you want to call a specific server-side method, that has to be done
server-side in an (ASP.NET) application that is executed when the specific
resource is requested, such as
<%@ LANGUAGE = JScript %>
<%= GetServerTime() %>
(Even though the interface is named XMLHttpRequest, you do not need to
return XML content; any output will do.)
HTH
PointedEars