Skip to main content

Posts

Showing posts from November, 2008

RYO AJAX script ...

Because I haven't posted anything for a litle while - I thought I'd dig out some old code and blog it in the name of consistency ...

So here's how to roll your own AJAX - to - .NET XML web-service call:

----------------------------------------------------------------------------
-- YOUR SAMPLE JAVASCRIPT FUNCTIONS --
----------------------------------------------------------------------------
// Get the XMLHttpRequest object
function getXmlHttpRequest()
{
if (window.XMLHttpRequest)
{
    xmlHttpRequest = new XMLHttpRequest();
}
else if (typeof ActiveXObject != "undefined")
{
    xmlHttpRequest = new ActiveXObject(" Microsoft.XMLHTTP");
}
return xmlHttpRequest;
}

// Send the text to server
function sendSelectedText()
{
var xmlHttpRequest = getXmlHttpRequest();
if (xmlHttpRequest != null)
{
    try
    {
 // send data to server
 var url = "http://" + location.hostname + "/AJAXSample/WebService.asmx/GetData?strParam=" + document.getElementById(txtBlah).value…