javascript - jquery加载函数在firefox中抛出 "XML Parsing Error: not well-formed"错误

标签 javascript jquery xml

尝试加载 xml 文件并收到 xml 解析错误。

$("#analyticForm_description").load('https://192.168.23.10/SystemServices/main?system:run=html/indicators/templates/editApp-definition.xml&Id=1000205&palletId=testtt', function() { MD.ui.editPallets.editform_definition(); } );

不应引发任何错误。请注意,提供的 URL 有效且可直接从浏览器访问。该函数也正在被调用。不知何故,即使在控制台上报告错误后,页面也成功加载。

不想看到控制台上报告的任何错误。

最佳答案

我认为 Firefox 需要 Content-Type,而 Chrome 会忽略它。

$.ajax({
    url : "https://192.168.23.10/SystemServices/main?system:run=html/indicators/templates/editApp-definition.xml&Id=1000205&palletId=testtt",
    contentType: "text/xml",
    success : function(response) {
        $("#analyticForm_description").html(response);
    }
});

或者对于加载方法使用 ajaxSetup :

Description: Set default values for future Ajax requests. Its use is not recommended.

$.ajaxSetup({
  contentType: "text/xml"
});

$("#analyticForm_description").load('https://192.168.23.10/SystemServices/...', function() { 
  MD.ui.editPallets.editform_definition();
});

关于javascript - jquery加载函数在firefox中抛出 "XML Parsing Error: not well-formed"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47708998/

相关文章:

javascript - html 表格水平滚动启用特定列

javascript - Google Picker API DocsUploadView setIncludeFolders 不起作用

php - 如何将 JSON 数组传递到 URL?

jQuery :last-child not working in IE8

javascript - 为什么函数在没有找到元素时运行?

java - 如何创建由辅助服务的元数据引用的 XML 文件?

C# WCF - 创建自定义消息内容

javascript - Ant Design - 带逗号小数分隔符的货币输入

c# - XML 序列化和继承类型

php - 更改/修改 Facebook 'Like it' 按钮的样式