Javascript Firefox在Ajax调用Asmx时暂停
最近,Firefox停止向.asmx.cs页面中的WebService WebMethod发送Ajax调用。基本上,FF甚至不会尝试打这个电话。我看到过其他类似问题的帖子,但到目前为止我还没有找到任何解决方案。这以前从来都不是问题(好像新的FF更新是罪魁祸首),下面的内容在Chrome和IE中似乎工作得很好。这就是Javascript:Javascript Firefox在Ajax调用Asmx时暂停,javascript,c#,jquery,asp.net,Javascript,C#,Jquery,Asp.net,最近,Firefox停止向.asmx.cs页面中的WebService WebMethod发送Ajax调用。基本上,FF甚至不会尝试打这个电话。我看到过其他类似问题的帖子,但到目前为止我还没有找到任何解决方案。这以前从来都不是问题(好像新的FF更新是罪魁祸首),下面的内容在Chrome和IE中似乎工作得很好。这就是Javascript: <script> $(document).ready(function () { var hash = 'JzVpYbr48'; v
<script>
$(document).ready(function () {
var hash = 'JzVpYbr48';
var dataS = JSON.stringify({ sessionHash: hash, customerID: '010000' });
$('#foo').on('click', function (event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: "http://localhost/MVRC/ad.asmx/GetAchievementsSummary",
contentType: 'application/json;charset=utf-8',
dataType: 'json',
data: dataS,
success: function (res) {
console.log("badges success");
},
error: function (res) {
console.log("badges failure");
}
});
});
});
</script>
值得一提的是,下面是web.config中一些可能相关的片段:
<location path="ad.asmx">
<system.web>
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
<conformanceWarnings>
<remove name="BasicProfile1_1" />
</conformanceWarnings>
</webServices>
</system.web>
</location>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
</customHeaders>
</httpProtocol>
</system.webServer>
浏览器控制台似乎没有显示任何错误。好吧,这很尴尬,但以下是我的发现。Firefox的add Block插件“add Block Plus”阻止了此ajax调用。然而,应该注意的是,我实际上设置了一个单独的Web表单测试解决方案,其中包含一个Web服务(asmx.cs),并对其进行了测试。通过Firefox和ADP的ajax调用也起到了作用。因此,我公司的产品与Firefox/ADP的结合是一个糟糕的组合。幸运的是,我们不支持ADP,所以我认为这不会是一个问题。然而,这就是我发现的。你在Firefox的控制台中调试过吗?文章中的“$.ajax”(“call”)代码没有说明问题(假设从
http://localhost
,无端口/相同架构)。确保文章中的信息允许重现问题。胡安,是的,我已经在Firefox的控制台中调试过了,它可以进入ajax。就像我说的,在其他浏览器中一切都可以正常工作。
<location path="ad.asmx">
<system.web>
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
<conformanceWarnings>
<remove name="BasicProfile1_1" />
</conformanceWarnings>
</webServices>
</system.web>
</location>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
</customHeaders>
</httpProtocol>
</system.webServer>