I have a. ASP.Net web service that is being called by a JS function that I want to return XML formatted code which is then used to populate a dropdown list.
I originally tried returning an object of type XMLWriter, but that didn't seem to work, so I just tried using a stringbuilder to create an xml structure to return to my JS complete function.
The XML I am returning is
In my JS function I am trying this, but am getting an errorCode:<catlist> <category> <ref>1</ref> <name>Item 1</name> </category> </catlist>
The error is result.getElementsByTagName is not a function.Code:function OnChangeComplete(result){ var catlist = result.getElementsByTagName('category'); if(catlist!=null){ var subcat = document.getElementById('ctl00_ddlsubcategory'); var opt = document.createElement('option'); for(var i=0;i<subcat.length;i++){ subcat.options[i].remove(); } for(var x=0;x<catlist.childNodes.length;x++) { opt.value = catlist[x].childNodes[0].nodeValue; opt.text = catlist[x].childNodes[1].nodeValue; subcat.options.add(opt,null); } } }
As far as I know this is a valid JS function to use on an XML document. See here.
Is it because I am returning a string to the JS function? How can I go about returning correct XML that can be processed by JS?



LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks