I am trying to get my phone number by getting xml info from xml website. The xml website was able to detect my userID computer and gave me a list of my profile included my phone number.
Here is example of xml displayed,
<MyData>
<user>
<uid>U580784</uid>
<sn>Bell</sn>
<givenName>James</givenName>
<initials>B</initials>
<Company>Happy Company</Company>
<Department>IT</Department>
<co>UNITED STATES</co>
<telephoneNumber>888-888-8888</telephoneNumber>
</user>
</MyData>
I want JQuery AJAX to get telephone number from <telephoneNumber> and display on alert box.
However I keep getting Ajax error thrown from error alert. Do I miss something?
you will see a xml link in AJAX below that have unique search UserID=me mean only detect when access to website or I can replace to UserID=U555555 to get other person phone number.
Here is my Jquery and asp codes,
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("#<%=Button1.ClientID %>").click(function () {
$.ajax({
type: "GET",
url: "http://servername.company.happy.com/common/components/userinfo/UserInfoXml.asp?UserID=me",
dataType: "xml",
success: function (xml) {
$(xml).find('user').each(function () {
var phone = $(this).find("telephoneNumber").text();
alert(phone);
});
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Error!'+ textStatus + ' - ' + errorThrown);
}
});
});
});
</script>
<h3>Test Test Header</h3>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<h3>Test Test Main</h3>
</br>
<asp:Button ID="Button1" runat="server" Text="Submit" />
</br>
</asp:Content>