开发者

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

I have AJAX call to one XML file and the source code is given below. It works perfectly in Chrome but is not working in Firefox. When doing debug I see that it doesn't enter to the cycle of $(response).find("simpleType").each(function() in Firefox.

Does anybody know what is the problem here in my code?

$.ajax({
  type:"GET",
  url:"views/workspace/branching_forms/StudentModelDescription.xml",
  dataType:"xml",
  error:function(XMLHttp开发者_Python百科Request, 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]));

  }
});

The content of StudentModelDescription.xml is given below:

<?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>


As per jQuery XML Ajax Call failing in... FIREFOX! make sure the server responds with the correct mime type header.


I have solved the problem in a very mysterious way. I removed xs: namespace from all XML tags, removed <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> and included all my XML code inside <someRootTag> ... </someRootTag> tags.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜