This article illustrates the method of jquery parsing XML file dynamically adding JS file at the same time. Share to everyone for your reference. The implementation methods are as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16-17 |
$ (function () {$.ajax {url: ' js/config/jsconfig.xml ', DataType: ' xml ', success:function (data) {$ (data). Find (" ModuleName "). each (function (i,obj) {var field = $ (this); var funcName = field.attr (' name '); for (var i = 0;i < Field.fin D ("func"). Size (); i++) {var func = Field.find ("Func:eq (" + i +) "). text (); var src = ' <script type= ' text/javascript "src=" "+ Func +". js "></script>"; $ ("Body"). Append (SRC); } }); } }); }) |
?
1 2 3 4 5 6 7 |
<?xml version= "1.0" encoding= "UTF-8"?> <module> <modulename name = "Admin" > <func>js/module/ testxml</func> <func>js/module/device</func> </moduleName> </module> |
I hope this article will help you with your jquery programming.