web服务-在firefox中使用javascript访问web服务时出现问题

web services - Problem accessing webservices using javascript in firefox

本文关键字:web 服务 访问 问题 javascript firefox      更新时间:2023-09-26

我正在尝试使用Javascript访问在.Net中构建的Web服务。

<html>
<head>
    <title>Test Web service</title>
    <script type="text/javascript">
        function httptest(){
            var http = new XMLHttpRequest();
            var params = "";
            var RetFlag = "Webmail-"+ false;            
            http.open("Post", "http://localhost:3624/_anet/wsCoverageValidate.asmx/CheckCoverage" , false);         
            http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            http.setRequestHeader("Content-length", params.length);
            http.setRequestHeader("Connection", "close");       
            http.onreadystatechange = function()
            {
                if(http.readyState == 4 && http.status == 200)
                {   
                    var resp=http.responseText; 
                    alert(resp);
                }
            }           
            http.send(params);      
        }
    </script>
</head>
<body>
    <div style="float: left; width: 100%; background-color: Gray;">
        <button id="btngo1" value="Go" type="submit" onclick="httptest()">
            Go
        </button>
    </div>
</body>
</html>

这是我的javascript html页面。现在它在InternetExplorer上运行良好,但在从firefox访问时会产生问题。它给了我作为的javascript错误

Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)

,在错误控制台中。我为此找了很多,但都没有成功。

请帮帮我。感谢

我已经得到了问题的答案,它无法在本地进行测试。Mozilla提供这种类型的安全性。

当我把我的html文件上传到我的服务器上并从我的电脑上调用时,它就可以正常工作了。]

我从这里得到了答案

谢谢大家。

下载jQuery并在HTML页面中添加源代码。

<script type="text/javascript" src="jquery.js"></script>  

请遵循本教程了解更多信息-http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery

访问Web服务

 <script type="text/javascript">
        function httptest(){
    $.post('http://localhost:3624/_anet/wsCoverageValidate.asmx/CheckCoverage', function(data) {
      alert(data);
    });
    </script>