开发者

Problem accessing webservices using javascript in firefox

I am trying to access my webservices that is build in .Net using Javascript.

<html>
<head>
    <开发者_StackOverflow中文版;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>

This is my html page with javascript. Now it runs fine with Internet Explorer, but it creates problem while accessing from firefox. It gives me javascript error as

Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)

, in Error console. I searched a lot for this, but yet no success.

Please help me. Thanks


I have got the answer for my issue, it cannot be tested on local. Mozilla provide such type of security.

When i uploaded my html file on my server and called from my PC then it works fine. ]

I got the answer from here

Thanks all.


Download jQuery and add the source in your HTML page.

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

Follow this tutorial for more information - http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery

To access a webservice

 <script type="text/javascript">

        function httptest(){

    $.post('http://localhost:3624/_anet/wsCoverageValidate.asmx/CheckCoverage', function(data) {
      alert(data);
    });
    </script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜