Friday, February 20, 2015

Getting data from a webservice

var xmlhttp = new XMLHttpRequest();
        if (window.XMLHttpRequest)
            xmlhttp = new XMLHttpRequest();
        else
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        xmlhttp.open("GET", SERVICEURL, false);
        xmlhttp.send();
        var xmlDoc = xmlhttp.responseXML;
        if (xmlDoc != null) {
                var email = xmlDoc.getElementsByTagName("email");//Here email is the field returned from the service
                if (email != null && email != undefined && email.length != 0) {
                    document.getElementById('<%= lblEmail.ClientID %>').innerHTML = email[0].childNodes[0].nodeValue;
                    document.getElementById('lnkEmail').setAttribute('href', "mailto:" + email[0].childNodes[0].nodeValue);
                }
            }
        }

No comments:

Post a Comment

How to launch a document by clicking a link to the file?

Word: <a href='ms-word:ofe|u|path/to/web/word/document.docx'>Link to document</a> Excel: <a href='ms-excel:o...