Home  >  Article  >  Backend Development  >  Jquery reads xml

Jquery reads xml

黄舟
黄舟Original
2017-02-15 15:51:391581browse

                                                                                         Please indicate the source when reprinting: Jquery reads xml

xml:

<forStatus>
  <values>
    <content>全勤</content>
    <el>F</el>
  </values>
  <values>
    <content>出差</content>
    <el>D</el>
  </values>
  <values>
    <content>差旅途中</content>
    <el>T</el>
  </values>
</forStatus>


Jquyery

var option = "";

$.get(&#39;../Handler/AttendanceStatus.xml&#39;, function (d) {
                $(d).find(&#39;values&#39;).each(function () {
                    var $val = $(this);
                    var el = $val.find("el").text();
                    var des = $val.find("content").text();
                    option += "<option value=\"" + el + "\">" + des + "</option>";
                    //alert(option);
                });
                strAttendanceStatusSelect = "<select id=\"selItem\" name=\"Item\">" + option + "</select>";
                //alert(strAttendanceStatusSelect);
            });

The above is the content of Jquery reading xml. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Statement:
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