Home > Web Front-end > JS Tutorial > How to parse XML files with jQuery and dynamically add js files

How to parse XML files with jQuery and dynamically add js files

php中世界最好的语言
Release: 2018-04-23 11:39:08
Original
1576 people have browsed it

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 = &#39;<script type="text/javascript" src=\"&#39; + func + ".js\"></script>";
     $("body").append(src);
    }
   });
  }
 });
})
Copy after login
<?xml version="1.0" encoding="UTF-8"?>
<module>
 <moduleName name = "管理">
 <func>js/module/testXml</func>
 <func>js/module/device</func>
 </moduleName>
</module>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template