Ste*_*vio 4 xml ajax firefox jquery find
我正在从XML文件中检索数据,然后使用jQuery .find()函数来访问该数据.但是在Firefox(版本37.0.2)中,我在JavaScript控制台中收到以下错误:
Error: Unable to run script because scripts are blocked internally.
Error: not well-formed
Source Code:
<datarecord><div><a id='sizzle1430853521804'></a><select id='sizzle1430853521804- ]' msallowcapture=''><option selected=''></option></select></
Run Code Online (Sandbox Code Playgroud)
一切仍然正常,但有谁知道如何摆脱这个错误,或者它是Firefox中的错误?
这是我的代码:
$.ajax({
url:"file.xml",
type:"GET",
dataType:"xml",
success:function(xml){
$(xml).find("field_id").each(function(){
// my code...
}
}
});
Run Code Online (Sandbox Code Playgroud)
XML文件具有以下格式,我使用了XML验证器来确保它没问题:
<?xml version="1.0" encoding="utf-8"?>
<datarecord>
<field_id><TheIdValue>8</TheIdValue><TheDisplayValue>Joe Bloggs</TheDisplayValue></field_id>
etc...
</datarecord>
Run Code Online (Sandbox Code Playgroud)
我一直无法找到解决方案.有什么建议?
我不能肯定地说它会解决你的问题,但是我在firefox中遇到了"格式不正确"的类似问题.事实证明,jQuery 1.11.2和1.11.3中存在一个错误 - https://github.com/jquery/jquery/issues/1969 - 它是固定在上游的.
如果您在服务器上托管jquery,这是一个相对较小的更改 - 请参阅github提交
在jquery.1.11.3.js line cca 1197(in QSA/matchesSelectorsection):
- "<select id='" + expando + "-\f]' msallowcapture=''>" +
+ "<select id='" + expando + "-\r\\' msallowcapture=''>" +
Run Code Online (Sandbox Code Playgroud)
希望很快会有新版本发布.