This time I will bring you jQueryHow to parse XML files and dynamically add js files. What are the notes of jQuery parsing XML files and dynamically adding js files? What are the following? This is a practical case, let’s take a look at it.
$(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.find("func").size();i++){ var func = field.find("func:eq(" + i + ")").text(); var src = '<script type="text/javascript" src=\"' + func + ".js\"></script>"; $("body").append(src); } }); } }); })
<?xml version="1.0" encoding="UTF-8"?> <module> <moduleName name = "管理"> <func>js/module/testXml</func> <func>js/module/device</func> </moduleName> </module>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Detailed explanation of the use of jquery plug-in uploadify
Detailed explanation of the use of jQuery to let browsers jump to each other and pass parameters
The above is the detailed content of How to parse XML files with jQuery and dynamically add js files. For more information, please follow other related articles on the PHP Chinese website!