Friday, February 20, 2015

Getting data from a webservice using an AJAX call

  $.ajax({
            url: SERVICEURL,
            type: "GET",
            headers: { "accept": "application/json;odata=verbose" },
            async: false,
            crossDomain: true,
            success: function (data) {
                var email = data.getElementsByTagName("person")[0].getElementsByTagName("email")[0]; //email is the field returned by the service
                if (email != null && email != undefined)
                    document.getElementById('lblEmail').innerHTML = email[0].childNodes[0].nodeValue
            },
            error: function (xhr) {
                console.log(xhr.status + ': ' + xhr.statusText);
            }
        });

No comments:

Post a Comment