Bhavik Goyal
Bhavik Goyal

Reputation: 2796

Problem accessing webservices using javascript in firefox

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

<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>

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

Upvotes: 2

Views: 486

Answers (2)

Raj
Raj

Reputation: 22926

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>

Upvotes: 1

Bhavik Goyal
Bhavik Goyal

Reputation: 2796

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.

Upvotes: 4

Related Questions