I have a ajax function with xml data type response. I need to assign this response as drop-down control. How can I access the values of Id and Name from the XML response?
I tried data[i].getElementsByTagName("Id")[0].childNodes[0].nodeValue; which doesn't gives me any value
$.ajax({
url: 'POWeb.asmx/GetStates?countryId=' + thisval,
success: function (data) {
var x = data.getElementsByTagName("KeyValueInt");
var html = ''
for (i= 0; i < length; i++) {
item = data[i].getElementsByTagName("Id")[0].childNodes[0].nodeValue;
value = data[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue;
html += '' + value + '';
}
html += '';
alert(html);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
//some stuff on failure
}
});
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
51
Ontario
52
Quebec
53
Nova Scotia