繁体   English   中英

jQuery.find()。each(fn)在Firefox中不起作用

[英]jQuery.find().each(fn) is not working in Firefox

我有一个XML文件的AJAX调用,下面给出了源代码。 它在Chrome中完美运行,但在Firefox中不起作用。 在进行调试时,我发现它没有进入Firefox中$(response).find(“ simpleType”)。each(function()的循环。

有人知道我的代码在这里出什么问题吗?

$.ajax({
  type:"GET",
  url:"views/workspace/branching_forms/StudentModelDescription.xml",
  dataType:"xml",
  error:function(XMLHttpRequest, textStatus, errorThrown){
      alert("error="+XMLHttpRequest+" error2="+textStatus+" error3="+errorThrown);
  },
  success:function(response){   
      var i=1;
      console.log("response="+response);
      $(response).find("simpleType").each(function(){                        
         adaptation_type_name[i]=$.trim($(this).find("documentation").text());                                                              
         var restriction = $(this).find("restriction[base=xs:string]");
         j=1;
         var values=new Array();        
         $(restriction).find("enumeration").each(function(){
            var tmp=$(this).attr("value");                                      
            values[j] = tmp;
            j++;
         });
         adaptation_type_variables[i]=values;               
         console.log("adaptation_type_name="+adaptation_type_name[i]+", adaptation_type_variables="+adaptation_type_variables[i]);
         i++;                        
      });                   
      for(var i=1;i<=adaptation_type_name.length;i++)                                       
        $('#adaptation_type_dialog #branching_adaptation_type').append($("<option></option>").attr("value",i).text(adaptation_type_name[i]));

  }
});

下面给出了StudentModelDescription.xml的内容:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleType name="browser" id="context_browser">
      <xs:annotation>
          <xs:documentation xml:lang="en">Web Browser</xs:documentation>
      </xs:annotation>
      <xs:restriction base="xs:string">
          <xs:enumeration value="Safari" id="1" />
          <xs:enumeration value="Google Chrome" id="2" />
          <xs:enumeration value="Opera" id="3" />
          <xs:enumeration value="Mozilla Firefox" id="4" />
          <xs:enumeration value="Internet Explorer" id="5" />
      </xs:restriction>
  </xs:simpleType>    
  <xs:simpleType name="networktype" id="context_networktype">
      <xs:annotation>
          <xs:documentation xml:lang="en">Network Type</xs:documentation>
      </xs:annotation>
      <xs:restriction base="xs:string">
          <xs:enumeration value="ADSL2+/Cable (High capacity)" id="1" />
          <xs:enumeration value="ADSL / HSPA (Moderate capacity)" id="2" />
          <xs:enumeration value="Dialup / GPRS (Low capacity)" id="3" />
      </xs:restriction>
  </xs:simpleType>
</xs:schema>

按照jQuery XML Ajax调用失败... FIREFOX! 确保服务器以正确的mime类型标题响应。

我已经以一种非常神秘的方式解决了这个问题。 我从所有XML标记中删除了xs:名称空间,删除了<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">并将我所有的XML代码都包含在<someRootTag> ... </someRootTag>标签。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM