当前位置:编程学习 > XML/UML >>

Jquery读取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('../Handler/AttendanceStatus.xml', function (d) {
                $(d).find('values').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);
            });

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,