java XML 解析错误:未找到元素位置:moz-nullprincipal(ajax 不强)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12157215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 07:49:36  来源:igfitidea点击:

XML Parsing Error: no element found Location: moz-nullprincipal (not strong with ajax)

javajqueryhtmlajaxtapestry

提问by newSpringer

I know this question has been asked many times and from what i have researched on this error it appears that it happens because cross domain ajax is only allowed for JSONP, not XML. But i am having trouble finding where this call is being made so I can't exactly find where the problem is. Everything is working fine until I added the following code

我知道这个问题已经被问过很多次了,从我对这个错误的研究来看,它的发生似乎是因为跨域 ajax 只允许用于 JSONP,而不是 XML。但是我很难找到打这个电话的地方,所以我无法确切地找到问题所在。一切正常,直到我添加了以下代码

@EventListener(targets="licensingStatus", events="onchange")
public void onLicenseStatusChange(IRequestCycle cycle){
    cycle.getResponseBuilder().updateComponent("licenceAuthRequiredDiv");
}

This is the component that the above code is updating

这是上面代码更新的组件

<div jwcid="licenceAuthRequiredDiv@Any">
      <span jwcid="@If" condition="ognl:company.licensingStatus == @com.fexco.wuams.valueobject.LicensingStatus@Pass && inApprovalMode()" renderTag="literal:false">
            <input jwcid="licensingApprovalDateRequired@DatePicker" disabled="ognl:disabled || isLicensingApprovalDateDisabled()"
            value="ognl:company.licensingApprovalDate" displayName="message:company.licensingApprovalDate" validators="validators:maxDateToday,required" />
     </span>
     <span jwcid="@Else" renderTag="literal:false">
            <input jwcid="licensingApprovalDate@DatePicker" disabled="ognl:disabled || isLicensingApprovalDateDisabled()"
            value="ognl:company.licensingApprovalDate" displayName="message:company.licensingApprovalDate" validators="validators:maxDateToday" />
      </span>
</div>

Using Firebug, when this is hit and moves through and a POST and GET requests are made and I get the following on the POST: 302 Moved Temporarilyand the GET request just hangs with the following: XML Parsing Error: no element found Location: moz-nullprincipal:{a752d6c1-8e61-4faf-9084-97124f7b3596} Line Number 1, Column 1:

使用 Firebug,当它被击中并移动并发出 POST 和 GET 请求时,我在 POST: 上得到以下内容:302 Moved Temporarily并且 GET 请求只是挂起以下内容:XML Parsing Error: no element found Location: moz-nullprincipal:{a752d6c1-8e61-4faf-9084-97124f7b3596} Line Number 1, Column 1:

I know it is not much to work with so if ye need anymore information just ask, but can anyone shine some light on this for me?

我知道这没什么可做的,所以如果你需要更多信息就问吧,但有人能帮我解释一下吗?

回答by Devanshu Bhimwal

firefox complain when the content-type being returned is XML, but the contents are empty.

当返回的内容类型是 XML,但内容为空时,firefox 会抱怨。

回答by Grigory Kislin

I've this problem because of dataType parameter in jQuery request: ajax response error(XML Parsing Error: no element found Location: moz-nullprincipal)?

由于 jQuery 请求中的 dataType 参数,我遇到了这个问题:ajax 响应错误(XML 解析错误:未找到元素位置:moz-nullprincipal)

回答by TomoMiha

Check for unclosed XML tags, firefox seems to report non-valid XML in existing file SAME ASnon-existant xml file. Chrome's inspector in Network panel reports more info: "error on line 2 at column 1: Extra content at the end of the document", and experienced developer should see this as unclosed tag problems.

检查未关闭XML标签,火狐似乎在现有的文件报告的非有效的XML SAME AS不存在的XML文件。网络面板中的 Chrome 检查器报告更多信息:“第 1 列第 2 行错误:文档末尾的额外内容”,有经验的开发人员应将此视为未关闭的标签问题。

Firefox reports: "Line Number 2, Column 1: ... XML Parsing Error: no root element found"

Firefox 报告:“第 2 行,第 1 列:... XML 解析错误:未找到根元素”

回答by Balint Bako

Probably the 302 redirecting you to another domain.

可能是 302 将您重定向到另一个域。