I'm pulling my hair for some time with this problem today. Will greatly appreciate if some one could provide me a solution.
I'm using ajax to get a list of categories to be populated in a dropdown.
My main code is below.
Expand|Select|Wrap|Line Numbers
- function makeRequest() {
- if (window.ActiveXObject)
- return new ActiveXObject("Microsoft.XMLHTTP");
- else if (window.XMLHttpRequest)
- return new XMLHttpRequest();
- else {
- alert("Your browser does not support AJAX.");
- return null;
- }
- }
- var http = makeRequest();
- function sendRequest(url, callbackfn) {
- http.open('get', url);
- http.onreadystatechange = callbackfn;
- http.send( null );
- }
Expand|Select|Wrap|Line Numbers
- var response = http.responseXML;
- var row = response.getElementsByTagName('topic');
when i do an alert
Expand|Select|Wrap|Line Numbers
- alert(row.length);
the xml returned by the php script is given below.
Expand|Select|Wrap|Line Numbers
- <?xml version="1.0"?>
- <topics>
- <topic id="1" title="Arithmetic"/>
- <topic id="2" title="Algebra"/>
- <topic id="3" title="Geometry"/>
- <topic id="4" title="Word Problems"/>
- <topic id="5" title="Miscellaneous"/>
- </topics>