我想訪問使用Javascript在.Net中構建的web服務。在Firefox中使用javascript訪問webservices時出現的問題
<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>
這是我的html頁面。現在,它可以在Internet Explorer中正常運行,但是它在從Firefox訪問時會產生問題。它給我的javascript錯誤爲
Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)
,在錯誤控制檯。我爲此搜尋了很多,但沒有成功。
請幫幫我。 謝謝
任何幫助Firebug? – emaillenin 2011-05-26 09:26:01
沒有。同時調試JavaScript發送到功能,而Web服務已被訪問。 – 2011-05-26 11:03:16
嘗試jQuery - 它是跨瀏覽器兼容 – emaillenin 2011-05-26 11:10:44