Пишу файл-менеджер на AJAX с помощью prototype.js сервер отдает XML следующего содержания: | Код | <answer> <element type="dir" name="."> <last-access>13-03-2007 11:03:08</last-access> <uid>1002</uid> <gid>80</gid> <perms>drwxr-xr-x</perms> </element> <element type="dir" name=".."> <last-access>13-03-2007 10:03:53</last-access> <uid>0</uid> <gid>0</gid> <perms>drwxr-xr-x</perms> </element> <element type="dir" name="public_html"> <last-access>13-03-2007 10:03:08</last-access> <uid>1002</uid> <gid>80</gid> <perms>drwxr-xr-x</perms> </element> <element type="file" name=".lesshst"> <last-access>21-02-2007 02:02:00</last-access> <uid>1002</uid> <gid>80</gid> <perms>-rw-------</perms> </element> <element type="dir" name=".ssh"> <last-access>13-03-2007 03:03:13</last-access> <uid>0</uid> <gid>80</gid> <perms>drwxr-xr-x</perms> </element> <element type="file" name=".bash_history"> <last-access>21-02-2007 02:02:00</last-access> <uid>1002</uid> <gid>80</gid> <perms>-rw-------</perms> </element> <element type="file" name="nohup.out"> <last-access>21-02-2007 02:02:00</last-access> <uid>1002</uid> <gid>80</gid> <perms>-rw-------</perms> </element> </answer>
|
Затем я хотел все это счастье распарсить и на базе этого вывести табличку с файлами. Но, почему-то, ничего не выводилось... В процессе дебаггинга (firebug) обнаружилось следующее: Это код функции: | Код | function build_tree(side, dir){ var pars = 'dir='+dir; this.finish = function(req){ // code for IE if (window.ActiveXObject){ var doc = new ActiveXObject("Microsoft.XMLDOM"); doc.async = "false"; doc.loadXML(req.responseText); } // code for Firefox, Opera, etc. else { var parser = new DOMParser(); var doc = parser.parseFromString(req.responseText,"text/xml"); } var x = doc.documentElement; console.info(x.childNodes.length); //выводит 7, все ок $H(x.childNodes).each(function(val, key){ console.log(x.childNodes[key].getAttribute('type')); //исправно показывает атрибут type тегов element console.log(val); //выводит ["0", element] (вместо "0", соответсвенно, индекс элемента) }); console.info(side+' here'); //и ВСЕ!! :( Сюда почему-то не доходит... Т.е. перебирает все элементы и скрипт прекращается return true; } new Ajax.Request(url, {method:'get', parameters:pars, onComplete:finish}); }
|
После перебора массива с помощью each() скрипт останавливается. Ошибок никаких не выдает. Кто-нибудь может объяснить подобное поведение?
--------------------
Все вышесказанное - имхо, и на истину в последней инстанции не претендует ------ UNIX and other
|